Thanx Ian,
it is still tracing null. Is this even possible to do. How do all the
big boys do dynamic instantation. What I basically want to achieve is
have a hashMap store different kinds of Command Objects. Instead of
instantiation at the start of the app, I would like to instatiated them
when the are required. The argument thing I can probably solve by adding
a method to the CommandObject interface like addParameters() The type
casting is the real problem here. I cant have the commands tracing as null..
Do you or anybody maybe have a solution?
Jiri
Ian Thomas wrote:
On a quick glance, I think this line is breaking it:
var constructor:Function = Function( _global );
because _global is not a function.
Try:
function createInstance ( classPath:String , args:Array) : Object
{
var packageList:Array = classPath.split( "." );
var constructor:Object = _global ;
while( packageList.length> 0 )
{
constructor = constructor[String(packageList.shift() )];
}
return Function(constructor).apply( constructor , args ) ;
}
On Fri, Apr 4, 2008 at 12:29 PM, Jiri Heitlager
<[EMAIL PROTECTED]> wrote:
Hello list,
Does anybody know an AS2 version of the AS method getDefinitionByName()
I would like to dynamic instantiated classes in AS2 with passing argument
to that created instance.
I am using a modified script from 'http://blog.generalrelativity.org/' ,
but the return datatype == null, even when I cast the returned instance.
import test.Shape
function createInstance ( classPath:String , args:Array) : Object
{
var packageList:Array = classPath.split( "." );
var constructor:Function = Function( _global );
while( packageList.length> 0 )
{
constructor = constructor[ String( packageList.shift() ) ];
}
return constructor.apply( constructor , args ) ;
}
var newShape:Shape = Shape ( createInstance('test.Shape' , [1,2,3]) )
trace( newShape ) //ouputs null, it should output Shape
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders