> Hi All,
> I'd like to provide a String value which represents the DisplayObject
> class I want to create dynamically with addChild. Has anyone
> accomplished this?
You mean like this?
public function createInstance (className : String) : Object {
var MyClass : Class = getClassByName(className);
return new MyClass();
}
Btw.: what I really miss is a method createInstance(args : Array) in
the Class class, so I could easily provide an arbitrary number of
constructor arguments not known until runtime, like this:
public function createInstance (className:String, args:Array) : Object {
var myClass : Class = getClassByName(className);
return myClass.createInstance(args);
}
Class.createInstance(args:Array) would be the constructor equivalent
of Function.apply(scope:Object, args:Array). If I use Function.apply
after I created an instance the constructor would be called twice
which would be quite dirty.
Consider this as a feature request... ;)
Jens
www.oregano-server.org
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/