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.
精彩评论