Using Expressions within Literals: embed ActionScript code directly into your XML data. : XML Object « XML « Flash / Flex / ActionScript






Using Expressions within Literals: embed ActionScript code directly into your XML data.

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var squareLength:Number = 10;
        var circleRadius:Number = 5;
        var shapeData:XML = <shapeList>
                               <shape type="square" size={squareLength} />
                               <shape type="cicle" size={circleRadius} />
                            </shapeList>;
        trace(shapeData.toXMLString());

    }
  }
}

        








Related examples in the same category

1.Creating an XML Object
2.Create the XML structure with a string
3.Understanding the XML Classes
4.Adding Attributes to an XML Element
5.Reading Elements in an XML Tree
6.Finding Elements by Name
7.Reading Text Nodes and Their Values