MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1273

Components language reference
Table of Contents

Advertisement

4.
Select the Tree instance. In the Property inspector, enter the instance name menuTree.
5.
Select the Tree instance and press F8. Select Movie Clip, and enter the name
TreeNavMenu.
6.
Click the Advanced button, and select Export for ActionScript.
7.
Type TreeNavMenu in the AS 2.0 Class text box and click OK.
8.
Select File > New and select ActionScript File.
9.
Save the file as TreeNavMenu.as in the same directory as treeMenu.fla.
10.
In the Script window, enter the following code:
import mx.controls.Tree;
class TreeNavMenu extends MovieClip {
var menuXML:XML;
var menuTree:Tree;
function TreeNavMenu() {
// Set up the appearance of the tree and event handlers.
menuTree.setStyle("fontFamily", "_sans");
menuTree.setStyle("fontSize", 12);
// Load the menu XML.
var treeNavMenu = this;
menuXML = new XML();
menuXML.ignoreWhite = true;
menuXML.load("TreeNavMenu.xml");
menuXML.onLoad = function() {
treeNavMenu.onMenuLoaded();
};
}
function change(event:Object) {
if (menuTree == event.target) {
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);
}
}
Using the Tree component (Flash Professional only)
1269

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents