ActionScript 2.0 Components Language Reference |
|
|
|
| Tree component > Tree.getDisplayIndex() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
treeInstance.getDisplayIndex(node)
node An XMLNode object.
The index of the specified node, or undefined if the node is not currently displayed.
Method; returns the display index of the node specified in the node parameter.
The display index indicates the item's position in the list of items that are visible in the tree window. For example, any children of a closed node are not in the display index. The list of display indices starts with 0 and proceeds through the visible items regardless of parent. In other words, the index is the row number, starting with 0, of the displayed rows.
The following example adds six nodes to a Tree and calls getDisplayIndex() to display the position of the node that the user selects.
You must first add an instance of the Tree component to the Stage and name it my_tr; 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, 140);
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='0' /><node label='Outbox' data='1' /></node><node label='3rd Local Folders'><node label='Inbox' data='0' /><node label='Outbox' data='1' /></node><node label='4th Local Folders'><node label='Inbox' data='0' /><node label='Outbox' data='1' /></node><node label='5th Local Folders'><node label='Inbox' data='0' /><node label='Outbox' data='1' /></node><node label='6th Local Folders'><node label='Inbox' data='0' /><node label='Outbox' data='1' /></node>");
my_tr.dataProvider = trDP_xml;
my_tr.firstVisibleNode = my_tr.getTreeNodeAt(0);
my_tr.addEventListener("change", listChanged);
function listChanged(evt_obj:Object) {
trace(my_tr.getDisplayIndex(evt_obj.target.selectedNode));
}
|
|
|
|