3 Replies Latest reply on Jun 16, 2012 5:21 AM by SHIVANG SANGHI

    Databinding issue

    untemps Level 1



      when I explicitely use databing in my development, I often encounter the following issue :


      I link an ArrayCollection with a view component, in order to provide the data to display, using the {} syntax in the skin mxml class.

      In the .as skinnable component class, I define a getter/setter bindable methods which store data, set a changing flag to false and call the invalidateDisplayList() method. In the updateDisplayList() method, I iterate through the ArrayCollection and I add visual items to the component display list.


      protected var _data:ArrayCollection;

      protected var _dataChanged:Boolean;



      public function get data():ArrayCollection


         return _data;



      public function set data( p_value:ArrayCollection ):void


         _data = p_value;

         _dataChanged = true;





      override protected function updateDisplayList( p_unscaledWidth:Number, p_unscaledHeight:Number ):void


         super.updateDisplayList( p_unscaledWidth, p_unscaledHeight );


         if( _dataChanged )


            // create and add items




      This mechanism works fine.


      But if I modify the original ArrayCollection using addItem() or removeItem() methods, which is supposed to be binded with the component, the setter is not called and nothing happens.


      I have to explicitely call the setter method and re-create an ArrayCollection for the component to update the display list.


      Is it the regular mechanism or do I miss something?