ArrayCollection中删除指定项的解决办法

http://riashanghai.com/zh-hant/node/96
在ArrayCollection中如果使用 for each 语句做循环,然后删除其中的item的话,常常会出现莫名的错误。原因是用for each语句的时候,删除其中的item,则index的获得有问题。

解决办法是用 ArrayCollection.source 获得数组,然后用for语句做循环,然后再根据index的值来删除。
代码示例:

for (var i:Number = this.groupSelectionControlArray.length-1; i>=0; i--){

。。。。。。。。。。。。

// remove it from the group selected arrayCollection
this.groupSelectionControlArray.removeItemAt(i);
}

你可能感兴趣的:(arrayCollection)