Explicitly typing variables causes compiler to think an instance of a builtin type doesn't have a pr

Posted by wallacoloo on Stack Overflow See other posts from Stack Overflow or by wallacoloo
Published on 2010-05-11T02:55:05Z Indexed on 2010/05/11 16:04 UTC
Read the original article Hit count: 217

I narrowed the causes of an AS3 compiler error 1119 down to code that looks similar to this:

var test_inst:Number = 2.953;
trace(test_inst);
trace(test_inst.constructor);

I get the error "1119: Access of possibly undefined property constructor through a reference with static type Number."

Now if I omit the variable's type, I don't get that error:

var test_inst = 2.953;
trace(test_inst);
trace(test_inst.constructor);

it produces the expected output:

2.953
[class Number]

So what's the deal? I like explicitly typing variables, so is there any way to solve this error other than not providing the variable's type?

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about compiler-errors