1 Reply Latest reply on Jan 1, 2011 2:34 PM by Shongrunden

    Binding in Flex 4

    Zolotoj Level 3

      I need some help understanding how binding is working in Flex 4.

      Here is some code:

      BindingUtils.bindProperty(general, "division", divisions, "dataToSelectedIndex");

       

      where general is an object with a public property "division".

       

      Divisions is a dropdownlist with the following definition:

      package modulecode
      {     
           
           [Bindble]
           import flash.events.Event;
           
           import spark.components.DropDownList;
      
           public class formDropDownList extends DropDownList
           {
                public function formDropDownList()
                {
                     super();
                }
                public function set dataToSelectedIndex(keyValue:int):void
                {
                     if (keyValue == 0)
                          selectedIndex = -1;
                     else
                          for (var i:int=0;i<dataProvider.length;i++)
                               if (Number(dataProvider[i]["id"].toString()) == keyValue)
                               {     
                                    selectedIndex = i;
                                    break;
                               }     
                }     
                public function get dataToSelectedIndex():int
                {
                     trace(selectedIndex);
                     return selectedIndex;
                }
           }
      }
      

      Somewhere ein the code I have this code:

      divisions.dataToSelectedIndex = 10;

       

      what I dont understand is why after this code divisions' getter is not called when dataToSelectedIndex has been changed.

       

      Please help.