Hi!,

I'm trying to do something pretty simple: dynamically instantiate a class based on it's name:

var n:String = "extremefx_comar.i18n.locales.EN_US";
var klass:Class = null;
try {
        klass = Class(getDefinitionByName(n));
        trace(describeType(klass));
                                
} catch (e:Error){
        trace("catch error:"+e);
}
                        
if (klass != null){
        trace(klass.test);
                                
        try {
                var ca:Object = new klass();
                trace(describeType(ca));
                                        
        } catch (e2:Error){
                trace("catch error:"+e2);
        }
}

The first trace works fine, no errors (so the describetype returns the correct XML for that class). Now, when I try to instantiate that class (var ca:Object = new klass()) i get the following error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

Also, the klass has a public static var "test". The trace(klass.test) returns undefined.

Ideas?

Thanks in advance,


--
Marcelo Volmaro

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to