views:

25

answers:

1

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?

A: 

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.

www.Flextras.com
It does but as I say in my post it fires several times for every change with a different event kind. I would rather an event related to the property as a property. As for images, it gets changed by assignment: images = collection
Tarek
Your original post didn't specify the "collectionChange" Event. Even so "images = collection" won't fire a collectionChange event. Show us your implementation of the images property. Did you make it Bindable? Does your set method fire a propertyChange event?
www.Flextras.com
Indeed that was the issue "images = collection". This was firing a CollectionChange event of kind 'update' when I was expecting 'add' or 'remove'. So the solution was either to use addItem on images or bypass it completely and bind my component to "collection"
Tarek