Build a property name and, consequently, an element name, dynamically : Bracket syntax « XML « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » XML » Bracket syntax 
Build a property name and, consequently, an element name, dynamically
 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:XML = <example />;
        
        var id:int 10;
        
        // Create a string to incorporate the value of id in the node name
        example"user" + id "";    
        
        traceexample );
    }
  }
}

        
Related examples in the same category
1.Bracket syntax is required for illegal property name
2.Adding Text Nodes to an XML Object
3.Use bracket notation, coupled with an integer, to access a particular element node
4.Use a variable's value as the element name to find:
5.XML text in a String into an actual XML object, whereas a cast would fail.
6.Accessing Values with E4X: Using the Dot Operator to Access Elements
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.