检测 Flex Spark List 的数据何时发生更改
我需要检测 Flex Spark List (spark.components.List
) 数据何时发生更改,以便我可以通过编程方式更改其滚动条。 我知道 List 是一个 EventDispatcher,但不清楚我要注册哪个事件。
编辑:我的列表的 dataProvider 是一个 ArrayCollection,也添加了元素。所以 dataProvider 永远不会被替换。我考虑过监听支持的 ArrayCollection,但列表可能会在监听器之后对更改做出反应,这会改变滚动条。因此,我的听众的更改将被列表的更改所取代。
I need to detect when a Flex Spark List (spark.components.List
) data has changed so that I can programmatically change its scrollbar.
I know that List is a an EventDispatcher but it's unclear which event I'd register for.
Edit: My List's dataProvider is an ArrayCollection that elements are added too. So the dataProvider is never replaced. I considered listening to the backing ArrayCollection, but it's possible the List will react to the change after my listener, which alters the scrollbar. Thus my listener's changes will be superseded by that of the List.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不向 ArrayCollection 添加一个 EventListener 并给它一个高 优先级?这将允许您侦听数据集合本身的更新事件,并强制您的侦听器首先发生。
编辑:我自己没有尝试过:^)
Why not add an EventListener to the ArrayCollection and give it a high priority? This would allow you to listen to update events on the data collection itself, and force your listener to occur first.
Edit: I've not tried this myself :^)
不知道现在还是这样吗!但你可以执行以下操作:
为您的 Spark 列表实现一个 itemRenderer 并使用 itemRenderer 的“dataChange”属性来查看数据何时更改?
像这样的东西:
你的列表:
现在在你的 itemRenderer 上
例如,在我的例子中,我试图删除列表中的每个项目,之后我的 itemRenderer 可以自动更新自身通过“数据更改”...
尽管您可以根据需要使用其他方法,例如
invalidateSize()
、invalidateLayering()
等。I don't know if it's still the case or not! But you could do following:
Implement an itemRenderer for your spark list and use 'dataChange' attribute of your itemRenderer to see when your data has been changed?
Something like this:
Your list:
Now on your itemRenderer
For example in my case I was trying to delete each items of my list, and after that my itemRenderer could update itself Automatically through 'dataChange'...
Although you can use others such as
invalidateSize()
,invalidateLayering()
and etc regarding your needs.