Bryan, I found another way to do this, using XMLListCollection.  Strangely, I still have to call invalidateList to get the tree to refresh.  My understanding was that the XMLListCollection methods would handle the needed events, but apparently not.

 

Tracy

 

            //deletes the currently selected node

            private function deleteSelectedNode():void

            {

                        var nodeToDelete:XML = XML(treeData.selectedItem);    //reference to the node to delete

                        var xlcParent:XMLListCollection = new XMLListCollection(nodeToDelete.parent().children()); //collection of nodes containing the node to delete

                        var iIndex:int = xlcParent.getItemIndex(nodeToDelete);    //index of node to delete in collection

                        xlcParent.removeItemAt(iIndex);    //remove the node

                        treeData.invalidateList();    //refresh the tree

            }//deleteSelectedNode

 


From: [email protected] [mailto:[email protected]] On Behalf Of Bryan Choi
Sent: Wednesday, May 24, 2006 4:22 AM
To: flexcoders
Subject: [flexcoders] Fw: [BETA3] I found how can remove the selected item of mx.controls.Tree.

 

 

----- Original Message -----

From: Bryan Choi

Sent: Tuesday, May 23, 2006 9:33 PM

Subject: [BETA3] I found how can remove the selected item of mx.controls.Tree.

 

Hi, all.

 

var treeItem :Object = mxTree.selectedItem;
  var parentItem :Object = mxTree.getParentItem ( treeItem );
  var items :ICollectionView = treeDD.getChildren (parentItem);
  var len :int = items.length;
  for ( var i:int=0; i<len; i++ )
  {
   if ( items [EMAIL PROTECTED] == [EMAIL PROTECTED] )
   {
    treeDD.removeChildAt ( parentItem, mxTree.selectedItem, i );
    break;
   }
  }

 

===========================

 

It is lengthy. so..

 

I want Anyone who has idea other to know simple code rather than above.

 

Thank you,

Brayn.




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to