MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 450

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 writes the names of the XML attributes to the log file:
// 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 written to the log file:
Val
first
XML.childNodes
Availability
Flash Player 5.
Usage
my_xml.childNodes:Array
450
Chapter 6: ActionScript Core Classes
associative array, the key index is a string representing the name of

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents