| Example |
//create instance of the Tree class
var tree:pseudo.Tree = pseudo.Tree.create(_root, "tree", 1);
tree.setSize(200, 350);
//Apply the skin to the Tree
tree.setLook(pseudo.look.XPLook.getInstance());
//Set cell class that will be used to render the tree items.
tree.setCellClass(classes.CellTree);
//Add some data to combobox. Data objects in the array should have three necessary flags:
// "text" this flag will be used to draw the item label , "cellType" to determine if the item is folder (1)or the leaf (0)
//"depth" is used to set an offset of the item in the tree
var arrData:Array = new Array();
arrData.push({text:"root 1", cellType:1, depth:0});
arrData.push({text:"leaf 1", cellType:0, depth:1});
arrData.push({text:"leaf 2", cellType:0, depth:1});
arrData.push({text:"folder", cellType:1, depth:1});
arrData.push({text:"leaf 1", cellType:0, depth:2});
arrData.push({text:"folder", cellType:1, depth:2});
arrData.push({text:"folder", cellType:1, depth:3});
arrData.push({text:"folder", cellType:1, depth:4});
arrData.push({text:"folder", cellType:1, depth:4});
arrData.push({text:"folder", cellType:1, depth:5});
arrData.push({text:"leaf 2", cellType:0, depth:2});
arrData.push({text:"leaf 3", cellType:0, depth:1});
arrData.push({text:"root 2", cellType:1, depth:0});
arrData.push({text:"leaf 1", cellType:0, depth:1});
arrData.push({text:"root 3", cellType:1, depth:0});
arrData.push({text:"leaf 1", cellType:0, depth:1});
arrData.push({text:"leaf 1", cellType:0, depth:0});
tree.setTreeData(arrData);
//
tree.expandAll();
tree.setSelId(0);
tree.update();
tree.draw();
// This code will draw the Tree element using XP look and feel skin.
// Please notice that you should always use some skin to create the component,
// this can be done like in this example, and the skin will be compiled into the swf file,
// or you can use another technique and load the skin at a run time.
|