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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

To view the entire script, see XML_languagePicker.fla in the ActionScript samples folder at at<br />

www.adobe.com/go/learn_fl_samples. Download <strong>and</strong> decompress the .zip file <strong>and</strong> navigate to<br />

the folder for your version of ActionScript to access the sample.<br />

See also<br />

appendChild (XMLNode.appendChild method), insertBefore (XMLNode.insertBefore<br />

method), removeNode (XMLNode.removeNode method)<br />

hasChildNodes (XMLNode.hasChildNodes method)<br />

public hasChildNodes() : Boolean<br />

Specifies whether or not the XML object has child nodes.<br />

Returns<br />

Boolean - true if the specified XMLNode has one or more child nodes; otherwise false.<br />

Example<br />

The following example creates a new XML packet. If the root node has child nodes, the code<br />

loops over each child node to display the name <strong>and</strong> value of the node. Add the following<br />

ActionScript to your FLA or AS file:<br />

var my_xml:XML = new XML("hankrudolph");<br />

if (my_xml.firstChild.hasChildNodes()) {<br />

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

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

aNode=aNode.nextSibling) {<br />

if (aNode.nodeType == 1) {<br />

trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);<br />

}<br />

}<br />

}<br />

The following is displayed in the Output panel:<br />

output:<br />

username: hank<br />

password: rudolph<br />

insertBefore (XMLNode.insertBefore method)<br />

public insertBefore(newChild:XMLNode, insertPoint:XMLNode) : Void<br />

Inserts a newChild node into the XML object's child list, before the insertPoint node. If<br />

insertPoint is not a child of the XMLNode object, the insertion fails.<br />

704 ActionScript classes

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

Saved successfully!

Ooh no, something went wrong!