Use bracket to access an attribute by name, or when the attribute name contains characters not allowed in variable names : At : XML Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » XML » At »

 

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;
        
        traceexample.@["bad-variable-name"] );
        
        traceexample.@["color" + num] );
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo XML
» At