View Full Version : [AS3] Yahoo! ASTRA - Tree Component Help
ShahSoft
03-10-2009, 12:40 PM
I wish to Add and Remove leafnodes or branchnodes to a Tree. I also want to Add more Leafs to a Branch.
I have tried many things like tree.addItem , tree.replaceItemAt, branchnode.addChildNode etc. I either run into errors or item added has no Labels. I know this works:
tree.addItem({label:"Ok"});
But how to use the same for adding Branches?
Can someone Please post working examples? How to make these work???
Thanks.
theAgonizer
08-27-2009, 10:16 PM
the astra frame work eventually type casts the objects that you add so though it appears that addItem({label:"test",nodeType:TreeDataProvider.LEAF_NODE,nodeLevel:1, parentNode:parentDp.rootNode, data:"some stuff"});
works, but it eventually will cause problems with the tree component, because the code further up the chain tries to type cast the object to a specific class.
try this instead:
import com.yahoo.astra.fl.controls.treeClasses.TreeDataPr ovider;
import com.yahoo.astra.fl.controls.treeClasses.TNode;
import com.yahoo.astra.fl.controls.treeClasses.LeafNode;
import com.yahoo.astra.fl.controls.treeClasses.BranchNode ;
import com.yahoo.astra.fl.controls.treeClasses.RootNode;
//myTree is an object on stage of type com.yahoo.astra.fl.controls.Tree
var parentDp:TreeDataProvider = mytree.dataProvider as TreeDataProvider;
var ln:LeafNode = new LeafNode(parentDp);
ln.label = "test";
ln.data = "";
ln.parentNode = parentDp.rootNode as BranchNode;
parentDp.addItem(ln);
If you want to create other types of nodes just change var ln:LeafNode = new LeafNode(parentDp); to a Branch node
www.designcortex.com
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.