User Guide

Using the Tree component (Flash Professional only) 1271
6. Enter the following code in the file:
<node>
<node label="Mail">
<node label="INBOX"/>
<node label="Personal Folder">
<node label="Business" isBranch="true" />
<node label="Demo" isBranch="true" />
<node label="Personal" isBranch="true" />
<node label="Saved Mail" isBranch="true" />
<node label="bar" isBranch="true" />
</node>
<node label="Sent" isBranch="true" />
<node label="Trash"/>
</node>
</node>
7.
Select Control > Test Movie.
In the SWF file, you can see the XML structure displayed in the tree. Click items in the
tree to see the
trace() statements in the change event handler send the data values to the
Output panel.
To use the TreeDataProvider class to create XML in Flash while authoring:
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 and 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.addTreeNode("Local Folders", 0);
// Use XML.firstChild to nest child nodes below Local Folders.
var myTreeNode:XMLNode = myTreeDP.firstChild;
myTreeNode.addTreeNode("Inbox", 1);
myTreeNode.addTreeNode("Outbox", 2);
myTreeNode.addTreeNode("Sent Items", 3);
myTreeNode.addTreeNode("Deleted Items", 4);
// Assign the myTreeDP data source to the myTree component.
myTree.dataProvider = myTreeDP;
// Set each of the four child nodes to be branches.
for (var i = 0; i<myTreeNode.childNodes.length; i++) {
var node:XMLNode = myTreeNode.getTreeNodeAt(i);
myTree.setIsBranch(node, true);
}