0
votes

The AS3 compiler says that acessing properties directly via the XML object is wrong. Is this legacy (AS2) code or should this work fine with the AS3 compiler? I'm told there is E4X supported within AS3 which allows for direct property access.

I'm compiling with FlashDevelop 4, Flex 4.5.1 and AIR 3.0 on Windows 7. I have -swf-version=13 set and I'm compiling in "strict mode". The code is from a mature AS3 library and should definitely compile. What am I doing wrong?

var node:XML;
var n:String = node.@name; // Access of possibly undefined property "name" through .. XML

Edit: This is not a runtime error which says that I can't access a property because the variable is null, its a compile time error, and prevents compilation of the project. Its the AS3 compiler refusing to allow compiling of a direct property access within an XML object.

2

2 Answers

0
votes

But your node in this code is undefined/null! You should get the «Cannot access a property or method of a null object reference» error! If you initialized node, then... have you tried cleaning the project and build it again? (it really helps sometimes)

0
votes

At variable declaration default value is null for objects, i.e. Sprite, XML, Array, Vector etc. And you can't get access to any property of null object.