If I do this I get all the traces:
(Document class)
package {
import flash.display.Sprite;
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import extremefx_comar.i18n.locales.EN_US;
public class Test extends Sprite {
public function Test():void {
trace(EN_US.test);
var n:String = "extremefx_comar.i18n.locales.EN_US";
var klass:Class = getDefinitionByName(n) as Class;
trace(klass);
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 error2:"+e2);
}
}
}
}
}
not sure if this helps though...
Kenneth Kawamoto
http://www.materiaprima.co.uk/
Marcelo Volmaro wrote:
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,
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders