User Guide

1270 Tree component (Flash Professional only)
This ActionScript sets up styles for the tree. An XML object is created to load the XML
file that creates the tree’s nodes. Then the
onLoad event handler is defined to set the data
provider to the contents of the XML file.
11. Create a new file called TreeNavMenu.xml in a text editor.
12. Enter the following code in the file:
<node>
<node label="My Bookmarks">
<node label="Macromedia Web site" url="http://www.macromedia.com" />
<node label="MXNA blog aggregator" url="http://www.markme.com/mxna"
/>
</node>
<node label="Google" url="http://www.google.com" />
</node>
13.
Save your documents and return to treeMenu.fla. Select Control > Test Movie to test
the application.
To load XML from an external file:
1. In Flash, select File > New and select Flash Document.
2. Drag an instance of the Tree component onto the Stage.
3. Select the Tree instance. In the Property inspector, enter the instance name myTree.
4. In the Actions panel on Frame 1, enter the following code:
var myTreeDP:XML = new XML();
myTreeDP.ignoreWhite = true;
myTreeDP.load("treeXML.xml");
myTreeDP.onLoad = function() {
myTree.dataProvider = this.firstChild;
};
var treeListener:Object = new Object();
treeListener.change = function(evt:Object) {
trace("selected node is: "+evt.target.selectedNode);
trace("");
};
myTree.addEventListener("change", treeListener);
This code creates an XML object called myTreeDP and calls the XML.load() method to
load an XML data source. The code then defines an
onLoad event handler that sets the
dataProvider property of the myTree instance to the new XML object when the
XML loads. For more information about the XML object, see its entry in ActionScript 2.0
Language Reference.
5. Create a new file called treeXML.xml in a text editor.