function openTree(t:mx.controls.Tree) { var i:Number=0; var node:mx.controls.treeclasses.TreeNode=t.getTreeNodeAt(i); while (node != undefined){ if (t.getIsBranch(node) && ! t.getIsOpen(node)){ t.setIsOpen(node,true); } i++; node=t.getNodeDisplayedAt(i); } }
At 01:25 PM 2/4/2005, you wrote:
Thanks for your help! This should make for an interesting afternoon�
Thanks again!
Rob
Robert L. Brueckmann Web Developer Merlin Securities, LLC 595 Madison Avenue New York, NY 10022 p: 212.822.4821 f: 212.822.4820
---------- From: Robert Stuttaford [mailto:[EMAIL PROTECTED] Sent: Friday, February 04, 2005 1:03 PM To: [email protected] Subject: RE: [flexcoders] tree traversal?
An addition:
Function findthatnode( parent node, nodeID ) {
Loop through parent node�s children:
If current child node is the one with nodeid, then
return current node
else if current child node has at least one child node of its own
return findthatnode( current child node, nodeid )
end loop
return null }
I might be making some major mistakes here, but thought some contribution is better than none; who knows, in correcting me you might �get� recursion!
---------- From: Robert Stuttaford [mailto:[EMAIL PROTECTED] Sent: 04 February 2005 07:57 PM To: [email protected] Subject: RE: [flexcoders] tree traversal?
Recursion, at it�s simplest, works like this:
function foo () { foo(); }
A function that calls itself � or, put another way, a function that calls a COPY of itself.
In pseudo code:
Function findthatnode( parent node, nodeID ) { Loop through parent node�s children: If current child node is the one with nodeid, then return current node else return findthatnode( current child node, nodeid ) }
That should be a good start!
Robert
---------- From: Robert Brueckmann [mailto:[EMAIL PROTECTED] Sent: 04 February 2005 07:39 PM To: [email protected] Subject: [flexcoders] tree traversal?
Is there any easy, recursive way to traverse a tree component? My tree�s data provider is an XML object sent from the db. I have 3 tree components actually�the 2nd tree is built based on the selection of the 1st tree and the 3rd tree is built based on the selections made in the 1st and 2nd trees. I want to implement a history manager for this 3-tree navigation and I�m having a hell of a time trying to reset a previously selected node�each node has a unique ID, so I�m saving this id to the state object for my custom history management and then I want to traverse the tree to find the last selected id when the user hits the back button�is there a simple way to just traverse through the tree, find the node with the id that matches the last selected id and then stop traversal? There�s no set structure to these trees�so I can�t depend on the trees always being the same size or to have the same number of branches, sub-branches, sub-sub-branches, etc�which is why I thought recursion would be my best bet but from the API and Flex docs, I can�t find a generic way to traverse the tree�all of their examples show the code explicitly finding a node at specific location and modifying the node�
I hate recursion, it has and will always confuse me to no end so any help with this would be most amazingly appreciated.
Thanks, Rob
Robert L. Brueckmann Web Developer Merlin Securities, LLC 595 Madison Avenue New York, NY 10022 p: 212.822.4821 f: 212.822.4820
----------
This message contains information from Merlin Securities, LLC, or from one of its affiliates, that may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify the sender immediately by telephone or by replying to this transmission.
Merlin Securities, LLC is a registered broker-dealer. Services offered through Merlin Securities, LLC are not insured by the FDIC or any other Federal Government Agency, are not deposits of or guaranteed by Merlin Securities, LLC and may lose value. Nothing in this communication shall constitute a solicitation or recommendation to buy or sell a particular security.
----------
This message contains information from Merlin Securities, LLC, or from one of its affiliates, that may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify the sender immediately by telephone or by replying to this transmission.
Merlin Securities, LLC is a registered broker-dealer. Services offered through Merlin Securities, LLC are not insured by the FDIC or any other Federal Government Agency, are not deposits of or guaranteed by Merlin Securities, LLC and may lose value. Nothing in this communication shall constitute a solicitation or recommendation to buy or sell a particular security.
----------
Yahoo! Groups Links
* To visit your group on the web, go to:
* <http://groups.yahoo.com/group/flexcoders/>http://groups.yahoo.com/group/flexcoders/
*
* To unsubscribe from this group, send an email to:
* <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
*
* Your use of Yahoo! Groups is subject to the <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.

