And here is a kinda complicated example of tree node manipulation: http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectI D=544
Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of John Robinson Sent: Tuesday, May 08, 2007 12:48 PM To: [email protected] Subject: Re: [flexcoders] Add a node to a tree programatically I'm running out the door but here's a quickie example. Note.. I'm not quite sure about adding a node while there is no node selected (aka, how to set selectedNode to the root node of the tree) <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " creationComplete="init()" > <mx:Script> <![CDATA[ public var selectedNode:XML; public function treeChanged(event:Event):void { selectedNode=Tree(event.target).selectedItem as XML; } public function addNode(event:Event):void { //add a node to the tree if(!selectedNode) { selectedNode = treeData[0]; } else { selectedNode.appendChild("<node label=\"added node\"/>"); } } ]]> </mx:Script> <mx:XMLList id="treeData"> <node label="Mail"> <node label="Inbox"> <node label="Marketing"/> <node label="Product Management"/> <node label="Personal"/> </node> <node label="Outbox"> <node label="Professional"/> <node label="Personal"/> </node> <node label="Spam"/> <node label="Sent"/> </node> </mx:XMLList> <mx:Tree id="my_tree" width="300" height="350" dataProvider="{treeData}" labelField="@label" change="treeChanged (event)"> </mx:Tree> <mx:Button label="add Node" click="addNode(event)"/> </mx:Application> On May 7, 2007, at 6:28 PM, Alejandro Narancio wrote: > Guys, > > I want to add a node programatically to a tree using ActionScript, > anybodoy know how can I do that? > > Thanks in advance, > Alex

