execute

Execute a Flash ActionScript method from a JScript module.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

method - String - The ActionScript method to be called.

args - Array - [Optional] - The arguments for the specified method represented as an array.


Output Parameters:

value - String - The string representation of the value returned by the executed command. The value is always the current value, not necessarily the value at the time of the command execution.


Notes:

The path to the method must originate in _level0 or _global, or be one of the intrinsic functions of the Flash Player. If you are calling a function from _global, you must specify "global" - _global without the inital underscore. Default path is _level0.

Intrinsic functions of the Flash Player (methods you must not provide a full path for) include:

·  duplicateMovieClip *
·  eval
·  fscommand
·  getTimer
·  getURL *
·  loadMovie *
·  loadMovieNum
·  loadVariables *
·  loadVariablesNum
·  play *
·  stop *
·  unloadMovie *
·  unloadMovieNum

* Unless you call the equivalent method on a MovieClip instance, e.g. my_mc.loadMovie.


Examples:

Example 1:
Example of calling the intrinsic getURL function.

Flash.execute({method:"getURL",args:["http://www.northcode.com","_blank"]});

Example 2:
Example of setting the label on a movieclip that has a function on it called setLabel. This setLabel function will return whether the command succeeded or not (true/false). We trace this value to the SWF Studio trace window.

var success_obj = Flash.execute({method:"_level0.my_mc.setLabel",args:["New Label"]});
trace(success_obj.value);

Example 3:
Example of executing an ssCore command to display a message in the trace window. You can execute this command directly using jsCommand, but this demonstrates the ability to execute a _global command, as well as the ability to pass objects as arguments that will be recognized as such on the Flash side (nested objects are not supported at this time).

Flash.execute({method:"global.ssCore.App.trace",args:[{text:"Hello World",color:"FF0000"}]});

Example 3:
An example of creating a new Textfield in our main movie and then setting some of its properties. Also see Flash.setVar.

Flash.execute({method:'_level0.createTextField',args:['my_txt',1,0,0,100,20]});
Flash.setVar({variable:'_level0.my_txt.border',value:'true'});
Flash.setVar({variable:'_level0.my_txt.borderColor',value:'0xFF0000'});
Flash.setVar({variable:'_level0.my_txt.autoSize',value:'left'});