Reputation: 9049
I've used the following code to dynamically retrieve and instantiate movieclips from the library that have linkage names:
var className:Class = getDefinitionByName(shortcutsArray[i][0]) as Class;
var object:Object = new className();
var mc:MovieClip = MovieClip(object);
It works, however what I want to do now is to instantiate my custom Class. So I would want to input a String which would be my class name: "myClass" and dynamically create var mc:myClass = new myClass(); But like I said, the above method does not work in this case.
Upvotes: 1
Views: 265
Reputation: 22604
Make sure you've included the class explicitly somewhere in your code. It won't be compiled into the binary, if there isn't at least one occasion where the class is used, and be it only a variable declaration.
Where there's no class, there can't be a dynamic instantiation... See this blog for more details.
Upvotes: 3