PDA

View Full Version : Tree Component within Accordion Component


forgueam
08-11-2005, 12:15 PM
I have dragged an instance of the Accordion component onto my movie, now I would like to programmatically (i.e. with actionscript) create a Tree component inside of the Accordion sections. Below is the code I am using, but it doesn't seem to work. Any suggestions?


CategoryHeader = Accordion.createChild("CategoryContainer", "CategoryHeader", {label: 'SomeName'});
CategoryMC = CategoryHeader.createEmptyMovieClip("CategoryMC", 10);

var MyTree = CategoryMC.createClassObject(mx.controls.Tree,"MyTree",5);

// 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;



Thanks in advance for any help!
Aaron

davej
06-08-2006, 06:01 PM
I am trying to do the same did you have any luck with this?

JohnThomasCraig
06-15-2006, 02:04 AM
I think your syntax for createChild is incorrect. Here's an example with nothing on the stage and a tree and an accordian in the library:


import mx.managers.DepthManager;
import mx.controls.Tree;
import mx.containers.Accordion;

var _folder_tree:Tree;
var _interface_acc:Accordion;

_interface_acc = this.createClassChildAtDepth(Accordion, DepthManager.kTop, {_name:"interface_acc"});
_interface_acc.setSize(Stage.width,Stage.height);
_folder_tree = Tree(_interface_acc.createChild(Tree,"folder_tree", {label:"All Documents"}));

_folder_tree.setDataProvider("<folder label=\"Stuff\"><file data=\"Stuff\" label=\"Stuff\" /><file data=\"Stuff\" label=\"Stuff\" /><file data=\"Stuff\" label=\"Stuff\" /><file data=\"Stuff\" label=\"Stuff\" /><file data=\"Stuff\" label=\"Stuff\" /></folder><folder label=\"Stuff\"><file data=\"Stuff\" label=\"Stuff\" /><file data=\"Stuff\" label=\"Stuff\" /></folder>");

stop();