Creates a new instance of a class object.


First available in version 3.0 build 2039.

Input Parameters:

variable - String - The full name of an ActionScript variable that will contain the reference to the new instance (e.g. "_level0.my_xml").

targetClass - String - The full name of the class object for which a new instance will be created (e.g. "XML").

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.


The path to the variable and targetClass must originate in _level0 or _global. If you are calling a function from _global, you must specify "global" - _global without the inital underscore. Default path for variable is _level0. Default path for targetClass is _global.


Example 1:
In this example we create a new instance of the TextFormat object, so we can manipulate a textfield residing in our main Flash movie.

var txtFmt_obj = Flash.setNew({variable:"_level0.txtFmt",targetClass:"TextFormat"});

Example 2:
Expanded example from above. Also see Flash.execute, Flash.setVar, and Flash.setDatatype.


var txtFmt_obj = Flash.setNew({variable:"_level0.txtFmt",targetClass:"TextFormat"});


var txtFmt_eval = Flash.setDatatype({type:"eval",value:"_level0.txtFmt"});

Example 3:
This example creates a new XML object in the main movie. We could then use other methods to manipulate the XML object. Tracing the value property of the returned object will always reveal the current value of the variable.

var myXML_obj = Flash.setNew({variable:"_level0.my_xml",targetClass:"XML"});