2 Replies Latest reply on Apr 18, 2013 9:27 AM by profesorAntonio

    Change Event dispatched 2 times in List Component



          Thanks for taking the time to read about my problem. I have a List component which has a simlpe array of strings as a dataprovider. I'm using the change event to call a method and I don't know why this method gets called 2 times.


      ¿Someone knows why this keeps happening?


      Thanks for your help.


      Sebastián Toro

        • 1. Re: Change Event dispatched 2 times in List Component
          hd465 Level 1

          Impossible to guess (show Your code ). I created a s:List component, set dataProvider and it works correctly (only one Alert appears when I select an item):



          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                         import mx.collections.ArrayCollection;
                         import mx.controls.Alert;
                         private var listFeed:ArrayCollection = new ArrayCollection(['A', 'B', 'C']);
                         protected function changeHandler(event:IndexChangeEvent):void {
               <s:List id="lista" dataProvider="{listFeed}"
          • 2. Re: Change Event dispatched 2 times in List Component

            If an s:List, you put a IndexChangeEvent listener the event, and in that event, cast a filterFunction to the dataProvider of that List ...
            You will have to validate inside that function through property IndexChangeEvent newIndex of greater than or equal to ZERO.
            Because interestingly, the dataProvider of the List filter is invoked IndexChangeEvent again, but now the newIndex, give a value of "-1", leading with it the entire event, from null and associated with this throw this:
            Error # 1009: Can not access a property or method of a null object reference.
            When referring to the event ... :/