You cannot enter data parameters in the Property inspector or in the Component inspector for
the Tree component as you can with other components. For more information, see
Tree component (Flash Professional only)" on page 759
Tree component" on page
Creating an application with the Tree component
The following procedures show how to use a Tree component to display mailboxes in an e-mail
application.
The Tree component does not allow you to enter data parameters in the Property inspector or
Component inspector. Because of the complexity of a Tree component's data structure, you must
either import an XML object at runtime or build one in Flash while authoring. To create XML in
Flash, you can use the TreeDataProvider interface, use the ActionScript XML object, or build an
XML string. Each of these options is explained in the following procedures.
To add a Tree component to an application and load XML:
In Flash, select File > New and select Flash Document.
1.
Save the document as treeMenu.fla.
2.
In the Components panel, double-click the Tree component to add it to the Stage.
3.
Select the Tree instance. In the Property inspector, enter the instance name menuTree.
4.
Select the Tree instance and press F8. Select Movie Clip, and enter the name TreeNavMenu.
5.
Click the Advanced button, and select Export for ActionScript.
6.
Type TreeNavMenu in the AS 2.0 Class text box and click OK.
7.
Select File > New and select ActionScript File.
8.
Save the file as TreeNavMenu.as in the same directory as treeMenu.fla.
9.
In the Script window, enter the following code:
10.
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) {
762
Chapter 6: Components Dictionary
762.
and
"Creating an application with the
"Using the
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?