开发者

Flex ArrayCollection bubble item up or down by one position

开发者 https://www.devze.com 2022-12-24 19:57 出处:网络
I have an ArrayCollection where I want to be able to bubble items up or d开发者_运维问答own by one position.What is the best way to do this?var ac:ArrayCollection = new ArrayCollection(yourArraySource

I have an ArrayCollection where I want to be able to bubble items up or d开发者_运维问答own by one position. What is the best way to do this?


var ac:ArrayCollection = new ArrayCollection(yourArraySource);
ac.removeItemAt(n); // where n > 0 and n < ac.length
ac.addItemAt( item, n-1); // where n>0 ... you should test for that

etc.


Combining Robusto's two function calls into a single line :)

ac.addItemAt(ac.removeItemAt(n), n-1);

The remove... functions on the ArrayList return the item being removed, so you can easily reposition it in the collection.

0

精彩评论

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