Tree.setIsBranch()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

treeInstance.setIsBranch(node, isBranch)

Parameters

node An XML node.

isBranch A Boolean value indicating whether the node is (true) or is not (false) a branch.

Returns

Nothing.

Description

Method; specifies whether the node has a folder icon and expander arrow and either has children or can have children. A node is automatically set as a branch when it has children; you only need to call setIsBranch() when you want to create an empty folder. You may want to create branches that don't yet have children if, for example, you only want child nodes to load when a user opens a folder.

Calling setIsBranch() refreshes any views.

Example

The following example adds a single node to a Tree instance called my_tr and calls setIsBranch() to make it a branch without children.

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, 100);

var trDP_xml:XML = new XML("<node label='Inbox' data='0'/>");
my_tr.dataProvider = trDP_xml;

// Set 1st node to be branch.
my_tr.setIsBranch(my_tr.getTreeNodeAt(0), true);