我正在尝试使用此代码交换 ArrayCollection 中的两个项目。
private function swapCollectionElements(collection:ArrayCollection, fromIndex:uint, toIndex:uint) : void
{
var curItem:Object = collection.getItemAt(fromIndex);
var swapItem:Object = collection.getItemAt(toIndex);
collection.setItemAt(curItem, toIndex);
collection.setItemAt(swapItem, fromIndex);
collection.refresh();
}
调试代码时,我可以看到 curItem 和 swapItem 是正确的对象,但是当我执行我的第一个 setItemAt 时,它会替换我想要的对象,但也会替换我不想要的对象。有什么想法吗?