4 Replies Latest reply on Apr 18, 2007 10:22 PM by romanczar

    COLLECTION_CHANGE event does not work on ArrayCollection

    romanczar Level 1
      Hi!
      I have a Panel component which has a public AC for its data. Work fine. Updates are correctl shown in charts.

      Inside my creationComplete-Method I now try to add an event listener for being able to notice changes. My code is

      dataFinanceYTDSingle.addEventListener(CollectionEvent.COLLECTION_CHANGE,manageDisplayedCom ponents);

      My handler:

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

      I get no output in debugging mode. Seems like the event does not get fired, but my charts change...

      I saw Adobe examples using <mx:ArrayCollection collectionChange="myHandler(event)" />...

      This worked, but I use AS to declare my Bindable ArrayCollection. And here it seem to be a bug...

      any ideas?
        • 1. Re: COLLECTION_CHANGE event does not work on ArrayCollection
          babo_ya Level 3
          What triggers the Collection_change event?
          and creationComplete method for your application or chart item?
          • 2. Re: COLLECTION_CHANGE event does not work on ArrayCollection
            romanczar Level 1
            Nothing specially triggers the event... I thought this is covered by the event listener...

            For your understanding: I add the eventlistener during the custom Panel's creationComplete event. I thought that when I now change the [Bindable] public dataFinanceYTDSingle (ArrayCollection) the event get fired anyway???
            • 3. Re: COLLECTION_CHANGE event does not work on ArrayCollection
              babo_ya Level 3
              Works fine for me...
              [Bindable]
              public var expenses:ArrayCollection; = new ArrayCollection([
              {Expense:"Taxes", Amount:2000, Cost:321, Discount:131},
              {Expense:"Rent", Amount:1000, Cost:95, Discount:313},
              {Expense:"Bills", Amount:100, Cost:478, Discount:841}
              ]);

              public function init():void //creationComplete function
              {
              expenses.addEventListener(CollectionEvent.COLLECTION_CHANGE, changeHandler);
              }

              //create a button and assign the click event to the below function....

              public function buttonClicked():void
              {

              var item:Object = new Object();
              item.Expense = "Melong";
              item.Amount = 1000;
              item.Cost = 333;
              item.Discount = 111;

              expenses.addItem(item);
              }

              • 4. Re: COLLECTION_CHANGE event does not work on ArrayCollection
                romanczar Level 1
                Hi.
                Thanks for your answer. Maybe it's due to my architecture...

                y Main app uses my Custom Component (Panel). My HTTPService is in my Application. When re-sending the HTTPService a resultHandler is called which parses my E4X. A temporary AC is set to

                myTempAC = new ArrayCollection()

                Then I loop through the E4X and add custom value objects:

                myTempAC.addItem(myCustomObj);

                Later the temp data is submitted by using

                <local:custPanel dataFinanceYTDSingle="{myTempAC}" />

                As I said, this works fine for charts and datagrid inside the Panel. But there seems to be no event firing...