[mtasc] classforName
Vladimir Dyuzhev
vladimir.dyuzhev at gmail.com
Thu Jun 9 01:22:34 CEST 2005
ehlo.
> I have a problem generate objects of dynamics types with the MTASC compiler.
> In Flash Compiler i maded this way:
> var className:String = "Matrix";
> var matrix:Array = new [className]( );
not sure what exactly do you want (why here is a array), but:
class ru.dozen.utils.ClassUtils
{
static function getInstanceOf(name,param0,param1,param2):Object
{
var ctor:Function = ClassUtils.getClassByName(name);
return new ctor(param0,param1,param2);
}
static function getClassByName(name):Function
{
return eval(name);
}
}
--
with best regards,
Vladimir Dyuzhev
http://dozen.ru
Non sunt entia multiplicanda praeter necessitatem
More information about the mtasc
mailing list