This code creates an XML object called
Tree component automatically receives all the properties and methods of the TreeDataProvider
interface. The second line of code creates a single root node called Local Folders. For detailed
information about the rest of the code, see the comments (lines preceded with
the code.
Select Control > Test Movie.
5.
In the SWF file, you can see the XML structure displayed in the tree. Click items in the tree to
see the
statements in the
trace()
panel.
To use the ActionScript XML class to create XML:
In Flash, select File > New and select Flash Document.
1.
Drag an instance of the Tree component onto the Stage.
2.
Select the Tree instance. In the Property inspector, enter the instance name myTree.
3.
In the Actions panel on Frame 1, enter the following code:
4.
// Create an XML object
var myTreeDP:XML = new XML();
// Create node values
var myNode0:XMLNode = myTreeDP.createElement("node");
myNode0.attributes.label = "Local Folders";
myNode0.attributes.data = 0;
var myNode1:XMLNode = myTreeDP.createElement("node");
myNode1.attributes.label = "Inbox";
myNode1.attributes.data = 1;
var myNode2:XMLNode = myTreeDP.createElement("node");
myNode2.attributes.label = "Outbox";
myNode2.attributes.data = 2;
var myNode3:XMLNode = myTreeDP.createElement("node");
myNode3.attributes.label = "Sent Items";
myNode3.attributes.data = 3;
var myNode4:XMLNode = myTreeDP.createElement("node");
myNode4.attributes.label = "Deleted Items";
myNode4.attributes.data = 4;
// Assign nodes to the hierarchy in the XML tree
myTreeDP.appendChild(myNode0);
myTreeDP.firstChild.appendChild(myNode1);
myTreeDP.firstChild.appendChild(myNode2);
myTreeDP.firstChild.appendChild(myNode3);
myTreeDP.firstChild.appendChild(myNode4);
// Assign the myTreeDP data source to the Tree component
myTree.dataProvider = myTreeDP;
For more information about the XML object, see its entry in Flash ActionScript Language
Reference.
Select Control > Test Movie.
5.
In the SWF file, you can see the XML structure displayed in the tree. Click items in the tree to
see the
statements in the
trace()
panel.
. Any XML object on the same frame as a
myTreeDP
event handler send the data values to the Output
change
event handler send the data values to the Output
change
Tree component (Flash Professional only)
) throughout
//
765
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?