Mega Code Archive

 
Categories / Flash ActionScript / XML
 

Use bracket to access an attribute by name, or when the attribute name contains characters not allowed in variable names

package{   import flash.display.Sprite;      public class Main extends Sprite{     public function Main(){         var example:XML = <example bad-variable-name="yes" color12="blue" />;         var num:Number = 12;                  trace( example.@["bad-variable-name"] );                  trace( example.@["color" + num] );     }   } }