Flex 组件属性更改事件
我有一个自定义组件,我已将数组集合绑定到其属性之一:
<comp:MyComp id="comp" prop="{images}" />
images is an arraycollection
在组件的代码中,我想知道每次图像更新 props 时要监听哪个事件。我尝试了 props 上的 setter 但setter 仅在首次设置 props 时被调用一次。我尝试了收集事件,但在“添加”和“删除”事件之上发送了“更新”事件,我宁愿不必管理这些事件。那么,每次可绑定属性更新组件属性时是否都会触发一个事件(flex 或其他)?
I have a custom component on which I have bound an array collection to one of its proeprties:
<comp:MyComp id="comp" prop="{images}" />
images is an arraycollection
In the components' code I would like to know which event to listen on everytime images updates props.I tried a setter on props but the setter only gets called once when props is first set. I tried the collection event but I get "Update" events sent on top of 'add' and 'remove' events and I would rather not have to manage those. So is there an event(flex or otherwise) that is fired every time a component property is updated by a bindable property?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你想听collectionChange 事件。每次 ArrayCollection 中的元素发生更改时,都会触发此事件。
请注意,更改图像源不会触发 collectionChange 事件,也不会触发 prop setter。
I think you want to listen to the collectionChange event on the prop property. This should fire every time an element in your ArrayCollection changes.
Be warned that changing the source of images not fire the collectionChange event, nor will it fire the prop setter.