03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - 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.

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 />

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 />

The following example is from the XML_languagePicker FLA file in the Examples directory<br />

<strong>and</strong> can be found in the languageXML.onLoad event h<strong>and</strong>ler function definition:<br />

// loop through the strings in each language node<br />

// adding each string as a new element in the language array<br />

for (var stringNode:XMLNode = childNode.firstChild; stringNode != null;<br />

stringNode = stringNode.nextSibling, j++) {<br />

masterArray[i][j] = stringNode.firstChild.nodeValue;<br />

}<br />

XMLNode 703

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

Saved successfully!

Ooh no, something went wrong!