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
to the
instance of the Tree component:
my_tr
You must first add an instance of the Tree component to the Stage and name it
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");
Most XML files contain white space. To make Flash ignore white space, you must set the
XML.ignoreWhite
dataProvider
property to
.
true
property to add the contents of an XML file
; then
my_tr
Tree.dataProvider
1289
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers