> I'm coding an introspection framework for as3, but i have a problem by
> creating instance at runtime without using new operator.

> I have no problem to create instances of classes with no operators at
> its construction function. The code is this one:

> public class ClassFactory{

>    public static function createInstance(className:String):Object
>              var clazz:Class = getDefinitionByName(className) as Class;
>              return new clazz()
>    }
> }

> I need a factory to create instance with an array of arguments, of this kind:

> public static function createInstance(name:String, args:Array):Object

> any idea??

Unfortunately this can't be done in AS3. I asked this before and the
workaround suggested by an Adobe engineer was to use a "well known
initialization method" in your classes and call them after invoking
the constructor. But this is obviously not feasible if you need to
work with existing classes and/or want to create a generic framework
with such capabilities. This is one of the areas where you have more
limitations in AS3 than you used to have in AS2. I really hope AS4
will introduce something like: Class.newInstance(args:Array)


Jens
www.oregano-server.org


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to