Salomonsson.se
Oct 04 2010

Error reading xml attribute when migrating from Flex 3 to 4.1

I have been struggling with several migration issues when going from flexSDK 3.2 to 4.1. This is another strange one…

// declare xml
var xmlList:XMLList = new XMLList( '<flashlet xmlElement="SimpleSprite" type="f3.ui.SimpleSprite" />
<flashlet xmlElement="SimpleRectangle" type="f3.ui.SimpleRectangle" />
<flashlet xmlElement="DebugFlashlet" type="f3.ui.DebugFlashlet" initWait="3000" />');

// Example 1
var name:String = "SimpleRectangle";
trace( xmlList.(@xmlElement == name ).toXMLString() );// nothing

// Example 2
var temp:String = "SimpleRectangle";
trace( xmlList.(@xmlElement == temp ).toXMLString() );// works

First example worked in flexSDK 3.x, but stopped working when compiling with flexSDK 4.1. Changing the variable name seemed to do the trickā€¦?!?