TreeDataProvider interface

The TreeDataProvider interface is a set of properties and methods and does not need to be instantiated to be used. If a Tree class is packaged in a SWF file, all XML instances in the SWF file contain the TreeDataProvider interface. All nodes in a tree are XML objects that contain the TreeDataProvider interface.

NOTE

The TreeDataProvider interface is supported only if you are working in a document that specifies ActionScript 2.0 in its Publish Settings.

It's best to use the TreeDataProvider methods to create XML for the Tree.dataProvider property, because only TreeDataProvider broadcasts events that refresh the tree's display. These are events that the Tree class handles; you do not need to write functions to handle these events. (The built-in XML class methods don't broadcast such events.)

Use the TreeDataProvider methods to control the data model and the data display. Use built-in XML class methods for read-only tasks such as traversing through the tree hierarchy.

You can select the property that holds the text to be displayed by specifying a labelField or labelFunction property. For example, the code myTree.labelField = "firstName"; results in the value of the property myTreeDP.attributes.fred being queried for the display text.

Method summary for the TreeDataProvider interface

The following table lists the methods of the TreeDataProvider interface.

Method

Description

TreeDataProvider.addTreeNode()

Adds a child node at the root of the tree.

TreeDataProvider.addTreeNodeAt()

Adds a child node at a specified location on the parent node.

TreeDataProvider.getTreeNodeAt()

Returns the specified child of a node.

TreeDataProvider.removeTreeNode()

Removes a node and all the node's descendants from the node's parent.

TreeDataProvider.removeTreeNodeAt()

Removes a node and all the node's descendants from the index position of the child node.

Property summary for the TreeDataProvider interface

The following table lists the properties of the TreeDataProvider interface.

Property

Description

TreeDataProvider.attributes.data

Specifies the data to associate with a node.

TreeDataProvider.attributes.label

Specifies the text to be displayed next to a node.