MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1321

Actionscript 2.0 language reference
Table of Contents

Advertisement

var oldest:XMLNode = doc.createElement("oldest");
var middle:XMLNode = doc.createElement("middle");
var youngest:XMLNode = doc.createElement("youngest");
// add the rootNode as the root of the XML document tree
doc.appendChild(rootNode);
// add each of the child nodes as children of rootNode
rootNode.appendChild(oldest);
rootNode.appendChild(middle);
rootNode.appendChild(youngest);
// use firstChild to iterate through the child nodes of rootNode
for (var aNode:XMLNode = rootNode.firstChild; aNode != null; aNode =
aNode.nextSibling) {
trace(aNode);
}
// output:
// <oldest />
// <middle />
// <youngest />
The following example is from the XML_languagePicker FLA file in the Examples directory
and can be found in the languageXML.onLoad event handler function definition:
// loop through the strings in each language node
// adding each string as a new element in the language array
for (var stringNode:XMLNode = childNode.firstChild; stringNode != null;
stringNode = stringNode.nextSibling, j++) {
masterArray[i][j] = stringNode.firstChild.nodeValue;
}
To view the entire script, see XML_languagePicker.fla in the ActionScript samples folder:
Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript
Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/
Samples/ActionScript
See also
appendChild (XMLNode.appendChild method)
,
method)
removeNode (XMLNode.removeNode method)
,
insertBefore (XMLNode.insertBefore
XMLNode
1321

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents