ActionScript 2.0 Components Language Reference |
|
|
|
| Tree component > Tree.addTreeNodeAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
Usage 1:
treeInstance.addTreeNodeAt(index,label[,data])
Usage 2:
treeInstance.addTreeNodeAt(index,child)
index The zero-based index position (among the child nodes) at which the node should be added.
label A string that contains the name of the node to add.
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 node at the specified location in the tree. The node is constructed either from the information supplied in the label and data parameters (Usage 1), or from the prebuilt 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. It uses the first usage of addTreeNodeAt() to add a new node, Inbox, to the first Tree. It then uses the second usage of addTreeNodeAt() to add the 1st node ((getTreeNodeAt(0)) from the second Tree to the first Tree.
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 node to first_tr.
first_tr.addTreeNodeAt(1, "Inbox", "data");
// Add the node from second_tr to first_tr.
first_tr.addTreeNodeAt(2, second_tr.getTreeNodeAt(0));
|
|
|
|