views:

183

answers:

1

Hi everybody,

I have a tree control and I want to give the user the ability that he can move up and down the element he just selected with a up and a downbutton. The tree gets generated from XML.

I managed to insert the selected item a second time at a other place, with the following code:

var parentXML:XML = XML(containerTree.selectedItem).parent();

var upperItem:XML = topContainer.source[containerTree.selectedIndex-1]; 

parentXML.insertChildBefore(upperItem,XML(containerTree.selectedItem));

but then I have the item there twice in the List. How can I remove to reinsert it?

Thanks for Hints! Markus

+1  A: 

Use the delete (XML) operator to remove XML nodes.

var parentXML:XML = XML(containerTree.selectedItem).parent();

var upperItem:XML = topContainer.source[containerTree.selectedIndex-1]; 

delete containerTree.selectedItem;

parentXML.insertChildBefore(upperItem,XML(containerTree.selectedItem));
Amarghosh