Xml.attributes - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

XML.attributes

Availability
Flash Player 5.
Usage
my_xml.attributes:Array
Description
Property; an associative array that contains all the attributes of the specified XML object.
Associative arrays use keys as indexes, instead of the simple ordinal integer indexes used by regular
arrays. In the
XML.attributes
the attribute. The value associated with that key index is the string value associated with that
attribute. For example, if you have an attribute named color, you would retrieve that attribute's
value by using the color as the key index, as the following code shows:
var myColor:String = doc.firstChild.attributes.color
Example
The following example shows the XML attribute names:
// create a tag called 'mytag' with
// an attribute called 'name' with value 'Val'
var doc:XML = new XML("<mytag name=\"Val\"> item </mytag>");
// assign the value of the 'name' attribute to variable y
var y:String = doc.firstChild.attributes.name;
trace (y);
// output: Val
// create a new attribute named 'order' with value 'first'
doc.firstChild.attributes.order = "first";
// assign the value of the 'order' attribute to variable z
var z:String = doc.firstChild.attributes.order
trace(z);
// output: first
The following is displayed in the Output panel:
Val
first
associative array, the key index is a string representing the name of
XML.attributes 1015

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents