Skip navigation
sebastiantoro84
Currently Being Moderated

Change Event dispatched 2 times in List Component

Sep 24, 2010 1:52 PM

Hi,

    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

 
Replies
  • Currently Being Moderated
    Sep 24, 2010 5:24 PM   in reply to sebastiantoro84

    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" 
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx"">
    
         <fx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   import mx.controls.Alert;
    
                   [Bindable]
                   private var listFeed:ArrayCollection = new ArrayCollection(['A', 'B', 'C']);
    
                   protected function changeHandler(event:IndexChangeEvent):void {
                        Alert.show('yah');
                   }
              ]]>
         </fx:Script>
    
         <s:List id="lista" dataProvider="{listFeed}"
                   change="changeHandler(event)"/>
    
    </s:Application>
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2013 9:27 AM   in reply to sebastiantoro84

    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 ... :/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points