To assign selectedChild, you need a reference to the acutal child.
Store an integer in the xml that relates to the index of the child in the viewstack, then set selectedIndex. Or have a switch statement that uses the @name to get the correct index. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of ryanharlin Sent: Thursday, December 06, 2007 2:19 PM To: [email protected] Subject: [flexcoders] navigation via mx:Tree I'd like to have an mx:Tree that acts as a navigation menu; where clicking an item in the Tree switches a viewStack to the corresponding page. I have an xml file with nodes that look like this: <section name="Folder 1" sectName="Folder 1" catID="1"> <subsection name="Item 1" subName="itemOne" /> <subsection name="Item 2" subName="itemTwo" /> </section> When rendered in a tree it creates a folder called Folder 1 with two sub-items called Item 1 and Item 2, respectively. I have a function that's triggered onChange for the tree that looks like this: public function treeChanged(event:Event):void { selectedNode=Tree(event.target).selectedItem; var myDestination:String = [EMAIL PROTECTED]; trace ([EMAIL PROTECTED]); } That runs fine. Clicking on a item in the Tree traces "itemOne" or "itemTwo" in the console. Now... I then have a viewStack with children named "itemOne" and "itemTwo." And I want to have the tree change read the newly selected item in the tree and go to the corresponding viewStack child. So I added this to the function: public function treeChanged(event:Event):void { selectedNode=Tree(event.target).selectedItem; var myDestination:String = [EMAIL PROTECTED]; myViewstack.selectedChild = [EMAIL PROTECTED]; } unfortunately, this doesn't work. does anyone see how to do this better?

