You don't need eval. Just use the [] syntax: var dynamicClass = "com.mycompany.myapp.SomeClassFromanXMLFile";
var obj:Object= new _global[dynamicClass]; Derek Vadneau http://tracethis.com ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Thursday, October 20, 2005 2:10 PM Subject: [Flashcoders] flex / actionscript 3 dynamic class instantiation Something I did in actionscript 2 was use the eval function to allow me to dynamically instantiate a class from a string. For example I have a xml document that specifies as particular class should be created, for example : var dynamicClass = "_global." + "com.mycompany.myapp.SomeClassFromanXMLFile"; var obj:Object= new (eval(dynamicClass)); looking at the actionscript 3 spec, eval has been removed, so how can we dynamically create a class from a classname ? This is something used a lot in JAVA and .NET and provides a powerful way to implement a "pluggable" interface. Cheers Grant _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

