I was working on a xml parser today and encountered an issue with AS3 e4x attribute access and the switch structure. When I used item.@name within switch() there were no traces…
switch(item.@name) { case "share" : trace(item.@name); break; case "requestBrochure" : trace(item.@name); break; case "gallery" : trace(item.@name); break; }
…but when I assigned item.@name to a string it worked
var n:String = item.@name; switch(n) { case "share" : trace(item.@name); break; case "requestBrochure" : trace(item.@name); break; case "gallery" : trace(item.@name); break; }
item.@name is of type Object. It needs to be cast to a string.
String(item.@name) would do as well.