Anyway I can do something like this:
var class_name:String = “MyClass”; // MyClass extends MovieClip
var myObject:MovieClip = new /class_name/(); // need to evaluate class_name
Thanks
Anyway I can do something like this:
var class_name:String = “MyClass”; // MyClass extends MovieClip
var myObject:MovieClip = new /class_name/(); // need to evaluate class_name
Thanks
Almost. Flash can do this, but you don’t use String, you use [U]Class[/U]:
var MyClass:Class = xyz;
var myObject:MyClass = new MyClass();
If you have a class name in a String, like “MovieClip”, there’s nothing you can do with it. But if you have the class’s entire definition in a String, like “flash.display.MovieClip”, you can pass it to the [U]getDefinitionByName()[/U] function to get the associated class. In reverse, if you have an Object and you want its class name, you can pass it to [U][URL=“http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getQualifiedClassName()”]getQualifiedClassName()[/U].
Finally, if you’re loading a SWF file into another SWF file, and you want one of the SWFs to be able to use the classes in the other one, you can access those classes with [U]ApplicationDomain.getDefinition()[/U].
var myButtonInstance:* = new (getDefinitionByName("myButton")) (param);
:: Copyright KIRUPA 2024 //--