ActionScript 2.0 Components Language Reference |
|
|
|
| Tree component > Tree.addTreeNode() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
Usage 1:
treeInstance.addTreeNode(label[,data])
Usage 2:
treeInstance.addTreeNode(child)
label A string that displays the node, or an object with a label field (or whatever label field name is specified by the labelField property).
data An object of any type that is associated with the node. This parameter is optional.
child Any XMLNode object.
The added XML node.
Method; adds a child node to the tree. The node is constructed either from the information supplied in the label and data parameters (Usage 1), or from the prebuilt child node, which is an XMLNode object (Usage 2). Adding a preexisting node removes the node from its previous location.
Calling this method refreshes the view.
The following example creates two Tree components with a node for each one, 1st Local Folders and 2nd Local Folders, respectively. Then it adds the tree node (2nd Local Folders) from the second Tree to the first Tree and also adds a new node, Inbox.
You must first add the component to the document library by dragging a Tree component to the Stage and then deleting it; then add the following code to Frame 1.
|
TIP |
First try this example without the two |
/**
Requires:
- Tree component in library
*/
import mx.controls.Tree;
this.createClassObject(Tree, "first_tr", 10);
first_tr.setSize(200, 100);
this.createClassObject(Tree, "second_tr", 20);
second_tr.setSize(200, 100);
second_tr.move(0, 120);
var trDP_xml:XML = new XML("<node label='1st Local Folders'><node label='Inbox' data='0'/><node label='Outbox' data='1'/></node>");
first_tr.dataProvider = trDP_xml;
var trDP2_xml:XML = new XML("<node label='2nd Local Folders'><node label='Outbox' data='0'/><node label='Outbox' data='1'/></node>");
second_tr.dataProvider = trDP2_xml;
// Add the node from second_tr to first_tr.
first_tr.addTreeNode(second_tr.getTreeNodeAt(0));
// Add node to first_tr.
first_tr.addTreeNode("Inbox", "data");
|
|
|
|