import test;
var dummy:test = new test(); //flash does not import the class unless it is instantiated, so the eval will fail without this line
var func = eval("test");
trace(typeof(func)); //func is equal to a function, or the test class constructor
var obj = new func;
trace(typeof(obj)); //obj is equal to the object type of test
Friday, June 1, 2007
Dynamic Object Instantiation
So you would think this would be pretty simple. An eval here an eval there and you would be done right? Nope. The reason this is difficult is because flash does not import a class even though you have the import statement in the actionscript unless the class is actually used. So the solution is to instantiate a dummy object, which will then force flash to import the class that is necessary to perform the eval().
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment