Tree.dataProvider

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

treeInstance.dataProvider

Description

Property; either XML or a string. If dataProvider is an XML object, it is added directly to the tree. If dataProvider is a string, it must contain valid XML that is read by the tree and converted to an XML object.

You can either load XML from an external source at runtime or create it in Flash while authoring. To create XML, you can use either the TreeDataProvider methods, or the built-in ActionScript XML class methods and properties. You can also create a string that contains XML.

XML objects that are on the same frame as a Tree component automatically contain the TreeDataProvider methods and properties. You can use the ActionScript XML or XMLNode object.

Example

The following example uses the dataProvider property to add the contents of an XML file to the my_tr instance of the Tree component:

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();
trDP_xml.ignoreWhite = true;
trDP_xml.onLoad = function(success:Boolean){ 
   my_tr.dataProvider = trDP_xml.firstChild;
}
trDP_xml.load("http://www.flash-mx.com/mm/xml/tree.xml");

NOTE

Most XML files contain white space. To make Flash ignore white space, you must set the XML.ignoreWhite property to true.