You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2015/04/29 18:35:08 UTC

Monitor collection change

I have an ArrayCollection. I need to monitor changes made to it by a user.
I am trying something like this:
aWatcher = ChangeWatcher.watch(_model.selectedPoints, "Selected",
validateSaveState);

private function validateSaveState(event:CollectionEvent):void
{
trace(event);
}

But I am not really getting into validateSaveState when selected property
is changed.

Please give me some ideas.

Thanks

Re: Monitor collection change

Posted by Alex Harui <ah...@adobe.com>.

On 4/29/15, 12:38 PM, "João Fernandes"
<jo...@gmail.com> wrote:

>Any change within items in this arrayCollection will result in a
>CollectionChangeEvent so you don't have to track items individually, just
>listen to the event on the ArrayCollection as Alex mentioned.

That is true, I forgot about that, but one warning: it assumes the data
objects are dispatching propertyChange events, and I think it also assumes
the object are flat.  I’m not sure it will pick up changes to properties
of sub-objects.

-Alex

>
>On 29 April 2015 at 20:18, mark goldin <ma...@gmail.com> wrote:
>
>> <Probably easier to do
>>addEventListener(CollectionEvent.COLLECTION_CHANGE).
>> Add it to what? To ArrayCollection? And how can I listen to each
>>element in
>> this collection?
>>
>> On Wed, Apr 29, 2015 at 1:39 PM, Alex Harui <ah...@adobe.com> wrote:
>>
>> > Probably easier to do
>> addEventListener(CollectionEvent.COLLECTION_CHANGE).
>> >
>> > That will pick up changes to the collection, but not to properties in
>> > object in the collection.  To do that, you will need to listen to each
>> > object in the collection.
>> >
>> > -Alex
>> >
>> > On 4/29/15, 9:35 AM, "mark goldin" <ma...@gmail.com> wrote:
>> >
>> > >I have an ArrayCollection. I need to monitor changes made to it by a
>> user.
>> > >I am trying something like this:
>> > >aWatcher = ChangeWatcher.watch(_model.selectedPoints, "Selected",
>> > >validateSaveState);
>> > >
>> > >private function validateSaveState(event:CollectionEvent):void
>> > >{
>> > >trace(event);
>> > >}
>> > >
>> > >But I am not really getting into validateSaveState when selected
>> property
>> > >is changed.
>> > >
>> > >Please give me some ideas.
>> > >
>> > >Thanks
>> >
>> >
>>
>
>
>
>-- 
>
>João Fernandes


Re: Monitor collection change

Posted by João Fernandes <jo...@gmail.com>.
Any change within items in this arrayCollection will result in a
CollectionChangeEvent so you don't have to track items individually, just
listen to the event on the ArrayCollection as Alex mentioned.

On 29 April 2015 at 20:18, mark goldin <ma...@gmail.com> wrote:

> <Probably easier to do addEventListener(CollectionEvent.COLLECTION_CHANGE).
> Add it to what? To ArrayCollection? And how can I listen to each element in
> this collection?
>
> On Wed, Apr 29, 2015 at 1:39 PM, Alex Harui <ah...@adobe.com> wrote:
>
> > Probably easier to do
> addEventListener(CollectionEvent.COLLECTION_CHANGE).
> >
> > That will pick up changes to the collection, but not to properties in
> > object in the collection.  To do that, you will need to listen to each
> > object in the collection.
> >
> > -Alex
> >
> > On 4/29/15, 9:35 AM, "mark goldin" <ma...@gmail.com> wrote:
> >
> > >I have an ArrayCollection. I need to monitor changes made to it by a
> user.
> > >I am trying something like this:
> > >aWatcher = ChangeWatcher.watch(_model.selectedPoints, "Selected",
> > >validateSaveState);
> > >
> > >private function validateSaveState(event:CollectionEvent):void
> > >{
> > >trace(event);
> > >}
> > >
> > >But I am not really getting into validateSaveState when selected
> property
> > >is changed.
> > >
> > >Please give me some ideas.
> > >
> > >Thanks
> >
> >
>



-- 

João Fernandes

Re: Monitor collection change

Posted by mark goldin <ma...@gmail.com>.
<Probably easier to do addEventListener(CollectionEvent.COLLECTION_CHANGE).
Add it to what? To ArrayCollection? And how can I listen to each element in
this collection?

On Wed, Apr 29, 2015 at 1:39 PM, Alex Harui <ah...@adobe.com> wrote:

> Probably easier to do addEventListener(CollectionEvent.COLLECTION_CHANGE).
>
> That will pick up changes to the collection, but not to properties in
> object in the collection.  To do that, you will need to listen to each
> object in the collection.
>
> -Alex
>
> On 4/29/15, 9:35 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >I have an ArrayCollection. I need to monitor changes made to it by a user.
> >I am trying something like this:
> >aWatcher = ChangeWatcher.watch(_model.selectedPoints, "Selected",
> >validateSaveState);
> >
> >private function validateSaveState(event:CollectionEvent):void
> >{
> >trace(event);
> >}
> >
> >But I am not really getting into validateSaveState when selected property
> >is changed.
> >
> >Please give me some ideas.
> >
> >Thanks
>
>

Re: Monitor collection change

Posted by Alex Harui <ah...@adobe.com>.
Probably easier to do addEventListener(CollectionEvent.COLLECTION_CHANGE).

That will pick up changes to the collection, but not to properties in
object in the collection.  To do that, you will need to listen to each
object in the collection.

-Alex

On 4/29/15, 9:35 AM, "mark goldin" <ma...@gmail.com> wrote:

>I have an ArrayCollection. I need to monitor changes made to it by a user.
>I am trying something like this:
>aWatcher = ChangeWatcher.watch(_model.selectedPoints, "Selected",
>validateSaveState);
>
>private function validateSaveState(event:CollectionEvent):void
>{
>trace(event);
>}
>
>But I am not really getting into validateSaveState when selected property
>is changed.
>
>Please give me some ideas.
>
>Thanks