5 Replies Latest reply on Nov 12, 2008 1:26 PM by lists.amrit@gmail.co

    ArrayCollection event listener

    SiHoop Level 1
      I'm trying to create an event listener for an ArrayCollection, but it does not work. I want to be able to trigger the function doThis when the value of the ArrayCollection changes. How should I setup my event listener properly?

      Thanks for your help!
        • 1. Re: ArrayCollection event listener
          ntsiii Level 3
          When you update an item in a collection directly, by assigning a property value, the collection does not know to fire off its events. ( If you use the collection API, it will.)

          When you do this, you can call itemUpdated(item) which should cause your handler to get called.

          • 2. Re: ArrayCollection event listener
            ntsiii Level 3
            Hmm, sorry, I think I misread your code.

            You are assigning the ArrayCollection, why not do your "doThis" processing there?

            • 3. Re: ArrayCollection event listener
              SiHoop Level 1
              My problem is that the 'doThis' function does not fire and I do not know why.
              • 4. Re: ArrayCollection event listener
                SiHoop Level 1
                Let me try to re-explain what I want to make happen. My goal is to understand how to create a listener for an ArrayCollection so that an event is triggered as soon as the contents of the ArrayCollection changes. I don't have any trouble loading data into the ArrayCollection, but I cannot figure out how to get notified when the loading has finished.
                I thought the following line would do the job, but it does not seem to work:

                • 5. Re: ArrayCollection event listener
                  I am trying to use the COLLECTION_CHANGE event too and in my case it seems to fire even when there is no change to the collection itself. I was wondering if you managed to use this event successfully and would like to share the code / point out my mistake.

                  sysList.addEventListener (CollectionEvent.COLLECTION_CHANGE, Function (addCustomCheck (ev,tableName,index)));

                  The source of this collection in the array does not change at all but the event is still fired. Any ideas why. What I am basically trying to do is to query that array collection's source (and array) for records after it has been populated by an asynchronous event preceding this.