`
keren
  • 浏览: 1558292 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

    博客分类:
  • Flex
 
阅读更多
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);
}
分享到:
评论
1 楼 qiqishou 2010-05-06  
好蛋疼的for...

相关推荐

Global site tag (gtag.js) - Google Analytics