1 Reply Latest reply on Apr 29, 2009 10:04 AM by Gregory Lafrance

    Day 2, Exercise 6 - Bindable ?

    ruby55555 Level 1



      The variable is bindable:

      [Bindable] public var selectedOptions:ArrayCollection;


      So, if I set the list data provider to this variable, like:

      <mx:list id="thelist" dataProvider="{selectedOptions}" />


      That means any change on the variable value will impact to list.

      The list will update automatically if bind variable value change.

      ( That's what I understood "Bindable" base on data grid example )


      Why this seems not working ?

      And we need add init()  ( trigger on creationComplete )


                  private function init():void {

                      selectedOptions.addEventListener(CollectionEvent.COLLECTION_CHANGE, addToList);



                  private function addToList(event:CollectionEvent):void {

                      thelist.dataProvider = selectedOptions;



      So, we are modify the dataProvider of list every time when the variable value changed.


      Why simply set the dataProvider and make the variable [Bindable] didn't work ? ( <mx:list id="thelist" dataProvider="{selectedOptions}" /> )



      Thank you for your help.