742
ActionScript classes
attributes (XMLNode.attributes property)
public attributes :
Object
An object containing all of the attributes of the specified XML instance. The XML.attributes
object contains one variable for each attribute of the XML instance. Because these variables
are defined as part of the object, they are generally referred to as properties of the object. The
value of each attribute is stored in the corresponding property as a string. For example, if you
have an attribute named color, you would retrieve that attribute's value by specifying color as
the property name, as the following code shows:
var myColor:String = doc.firstChild.attributes.color
Availability:
ActionScript 1.0; Flash Lite 2.0
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
childNodes (XMLNode.childNodes property)
public childNodes :
Array
[read-only]
An array of the specified XML object's children. Each element in the array is a reference to an
XML object that represents a child node. This is a read-only property and cannot be used to
manipulate child nodes. Use the
appendChild()
,
insertBefore()
, and
removeNode()
methods to manipulate child nodes.
This property is undefined for text nodes (
nodeType == 3
).
Availability:
ActionScript 1.0; Flash Lite 2.0
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...