Is there a way to call an object's methods?

DLL Edition of the F-IN-BOX
Guest

Is there a way to call an object's methods?

Postby Guest » Mon Aug 15, 2005 5:22 am

I know you can use SetVariable to set a variable, but is there a way to invoke an object methods?

Here's an example:

here's the GetVariable info about an object:

{evalue:'0x08027F',kill:{},vartrace:{},failed:{},c heck:{},encrypt:{},isastring:{},unes:{},es:{},show Trace:{},showEvalue:{},showValue:{},show:{},change By:{},changeTo:{},formatvalue:{},maxplaces:10,plac es:2,value:'0',formatnumbervalue:{},formatstringva lue:{},traceon:1,index:5,mynameme:{},mycreateme:{} ,include_level:100,comment:,name:'',getHelp:{}}

I can set the 'value' and similar fields, but can't do anything with things like kill:{} and the like.

Is there anyway to do this or is it just impossible?

Opera362

Use Proxy workaround (TCallLabel)

Postby Opera362 » Fri Sep 09, 2005 8:40 am

Hi guest,

In the meanwhile (before final Flash 8 arrives) you can use a workaround to achieve that. You can set variables used in a function call, and afterwards call that function. The function will use the actual values from the values previously set.

How to call a Flash-defined function? The steps are:

In Flash Movie:
1) Create new MovieClip mcCaller, and do inside of it:
1.1) Define as many keyframes as functions you want to invoke
1.2) Label each defined keyframe as the name of the function
1.3) Place the code of the function (followed by stop();) in each frame, or make a call to the actual method in an actual object
1.4) If you want, put some artwork (like a rectangle) to add some visibility in the library

2) Drag an instance of mcCaller into the Movie, and call it "caller_mc"

3) Define at _root level as many variables as different parameters you will use with your function calls

4) Modify mcCaller to suit your needs for each new function you want to invoke from outside (thas is: expose the internal methods to outside)


From your Application:
1) If the function call is: myFunction("John Smith", 55)
1.1) SetVariable("_root.param1", "John Smith")
1.2) SetVariable("_root.param2", 55)
1.3) TCallLabel("_root.caller_mc", "myFunction")


It works perfectly, maybe not so elegant, but with Flash < 8 that's the only way. I think in Flash 8 there are some new functions to clean achieve this


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 15 guests

cron