开发者

flex: move item around in a tree control

I have开发者_如何学JAVA 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


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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜