03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

firstChild (XMLNode.firstChild property)<br />

public firstChild : XMLNode [read-only]<br />

Evaluates the specified XML object <strong>and</strong> references the first child in the parent node's child<br />

list. This property is null if the node does not have children. This property is undefined if<br />

the node is a text node. This is a read-only property <strong>and</strong> cannot be used to manipulate child<br />

nodes; use the appendChild(), insertBefore(), <strong>and</strong> removeNode() methods to<br />

manipulate child nodes.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Example<br />

The following example shows how to use XML.firstChild to loop through a node's child<br />

nodes:<br />

// create a new XML document<br />

var doc:XML = new XML();<br />

// create a root node<br />

var rootNode:XMLNode = doc.createElement("rootNode");<br />

// create three child nodes<br />

var oldest:XMLNode = doc.createElement("oldest");<br />

var middle:XMLNode = doc.createElement("middle");<br />

var youngest:XMLNode = doc.createElement("youngest");<br />

// add the rootNode as the root of the XML document tree<br />

doc.appendChild(rootNode);<br />

// add each of the child nodes as children of rootNode<br />

rootNode.appendChild(oldest);<br />

rootNode.appendChild(middle);<br />

rootNode.appendChild(youngest);<br />

// use firstChild to iterate through the child nodes of rootNode<br />

for (var aNode:XMLNode = rootNode.firstChild; aNode != null; aNode =<br />

aNode.nextSibling) {<br />

trace(aNode);<br />

}<br />

// output:<br />

// <br />

// <br />

// <br />

1342 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!