Flex ArrayCollection 将项目向上或向下气泡一个位置

发布于 2024-08-26 07:47:00 字数 57 浏览 6 评论 0原文

我有一个 ArrayCollection,我希望能够将项目向上或向下冒泡一个位置。最好的方法是什么?

I have an ArrayCollection where I want to be able to bubble items up or down by one position. What is the best way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淑女气质 2024-09-02 07:47:00
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。

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.

南七夏 2024-09-02 07:47:00

将 Robusto 的两个函数调用组合成一行:)

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

ArrayList 上的 remove... 函数返回被删除的项目,因此您可以轻松地在集合中重新定位它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文