View Full Version : tree component
Paulskii
04-28-2008, 10:20 PM
I have a tree component that I want to have the following functionality...
I want only one branch open at a time...so when the user expands the first branch it reveals all of its items inside that branch...then when the user chooses a second branch (without first closing the first branch) the first branch will collapse and only the new selected branch will have all of its items visible...I tried to store the nodes in an array, and then just close the node with array[index-1] but I cannot seem to be able to store the nodes, or even the index of the nodes in an array...are there any efficient way of doing this?
evride
04-29-2008, 01:26 AM
are you making a custom tree component? if so i suggest stop now and look at yahoo astra components. they have a really easy to use tree component that would do what you want. just look through the API documentation.
Paulskii
04-29-2008, 02:08 PM
im actually not using a custom tree component...its the one from the flash components library...and it seems to be doing everything I need except for one thing...which I will figure out...thank you for the suggestion though, I will check out what they have just to see
Paulskii
04-29-2008, 09:41 PM
Solution: store the index of the selected item in an array...then use getTreeNodeAt(arrayIndex-1) to get the previous node...but be careful because if no branches are open the branch indexes are 0, 1, 2, 3...but as soon as one is open...those change...so if branch one has 2 items...branch 1 index is still 0 but branch 2 index is now 3 because the two items within branch 1 take up index 1&2...this got me...and I was confused...I hope I didnt confuse anyone with this...if you have questions feel free to get at me...
var nodeArray:Array = new Array();
var nodeCounter:Number = 0;
var nodeIndex:Number = treeInstance.selectedIndex;
nodeArray[nodeCounter] = nodeIndex;
if(treeInstance.getIsOpen(treeInstance.getTreeNode At(nodeArray[nodeCounter-1])) && (node != treeInstance.getTreeNodeAt(nodeArray[nodeCounter-1])))
{
treeInstance.setIsOpen(treeInstance.getTreeNodeAt( nodeArray[nodeCounter-1]), false);
nodeIndex = treeInstance.selectedIndex;
nodeArray[nodeCounter] = nodeIndex;
}
nodeCounter++;
evride
04-29-2008, 10:13 PM
o sorry, i assumed you were using CS3 with actionscript 3 where there is no Adobe supplied tree component.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.