MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1274

Components language reference
Table of Contents

Advertisement

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
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
load an XML data source. The code then defines an
property of the
dataProvider
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.
1270
Tree component (Flash Professional only)
event handler is defined to set the data
onLoad
and calls the
myTreeDP
instance to the new XML object when the
myTree
XML.load()
event handler that sets the
onLoad
method to

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents