MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 763

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

var node = menuTree.selectedItem;
// If this is a branch, expand/collapse it
if (menuTree.getIsBranch(node)) {
menuTree.setIsOpen(node, !menuTree.getIsOpen(node), true);
}
// If this is a hyperlink, jump to it
var url = node.attributes.url;
if (url) {
getURL(url, "_top");
}
// Clear any selection
menuTree.selectedNode = null;
}
}
function onMenuLoaded() {
menuTree.dataProvider = menuXML.firstChild;
menuTree.addEventListener("change", this);
}
}
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
to the contents of the XML file.
Create a new file called TreeNavMenu.xml in a text editor.
11.
Enter the following code in the file:
12.
<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>
Save your documents and return to treeMenu.fla. Select Control > Test Movie to test the
13.
application.
To load XML from an external file:
In Flash, select File > New and select Flash Document.
1.
Drag an instance of the Tree component onto the Stage.
2.
Select the Tree instance. In the Property inspector, enter the instance name myTree.
3.
In the Actions panel on Frame 1, enter the following code:
4.
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("");
event handler is defined to set the data provider
onLoad
Tree component (Flash Professional only)
763

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents