Flex:CollectionChangeEvent 无法由removeAll() 触发
代码如下:
[Bindable]
public var abc_list:ArrayCollection;
...
this.abc_list.removeAll();
this.abc_list.addAll(otherCollection);
...
this.abclist.addEventListener(CollectionChangeEvent.COLLECTION_CHANGE, onCollectionChange)
我发现在removeAll()之后无法触发事件,但在addAll(otherCollection)[with event.type]中效果很好。
所以在添加新列表之前并没有删除原来的列表;而abc_list居然是累加的?!
为什么会这样呢?我能用它做什么?
the code is like the following:
[Bindable]
public var abc_list:ArrayCollection;
...
this.abc_list.removeAll();
this.abc_list.addAll(otherCollection);
...
this.abclist.addEventListener(CollectionChangeEvent.COLLECTION_CHANGE, onCollectionChange)
I found that the event cannot be triggered after the moment of removeAll(), but it works well in addAll(otherCollection) [with event.type].
So the original list is not removed before the new list is added;And the abc_list is actually accumulated?!
Why is it happen? and What can I do with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能很老套,我正在大声思考这一点,因为我还没有检查它
并等待刷新时使用 CollectionEventKind.REFRESH 的 CollectionEvent 事件
May be hacky and I'm thinking this out loud as I haven't checked it
and wait for a CollectionEvent event with the CollectionEventKind.REFRESH upon refresh
*this.abclist.addEventListener(CollectionChangeEvent.COLLECTION_CHANGE, onCollectionChange)*
是自定义事件吗?
我正在使用 CollectionEvent.COLLECTION_CHANGE 并且它与 removeAll() 方法一起工作正常。我希望使用 CollectionEvent.COLLECTION_CHANGE 可以解决您的问题。
*this.abclist.addEventListener(CollectionChangeEvent.COLLECTION_CHANGE, onCollectionChange)*
Is it custom event ?
I am using CollectionEvent.COLLECTION_CHANGE and it works fine with removeAll() method. I hope using CollectionEvent.COLLECTION_CHANGE solves your problem.