ActionScript 2.0 Components Language Reference |
|
|
|
| Tree component > Tree.removeTreeNodeAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
treeInstance.removeTreeNodeAt(index)
index The index number of a tree child. Each child of a tree is assigned a zero-based index in the order in which it was created.
An XMLNode object, or undefined if an error occurs.
Method; removes a node (specified by its index position) on the root of the tree and refreshes the tree.
The following example adds two nodes to a Tree instance and creates a listener for a change event on the tree. When a change event occurs, the listener functions call the removeTreeNodeAt() method to delete the selected node from the tree.
You first add an instance of the Tree component to the Stage and name it my_tr and then add the following code to Frame 1.
/**
Requires:
- Tree component on Stage (instance name: my_tr)
*/
var my_tr:mx.controls.Tree;
my_tr.setSize(200, 100);
var trDP_xml:XML = new XML("<node label='1st Local Folders'><node label='Inbox' data='0' /><node label='Outbox' data='1' /></node><node label='2nd Local Folders'><node label='Inbox' data='2' /><node label='Outbox' data='3' /></node>");
my_tr.dataProvider = trDP_xml;
var treeListener:Object = new Object();
treeListener.change = function (evt_obj:Object) {
my_tr.removeTreeNodeAt(my_tr.selectedIndex);
}
my_tr.addEventListener("change", treeListener);
|
|
|
|