3 Replies Latest reply on Jan 18, 2011 10:54 AM by Flex harUI

    combo box selected index is not working.


      Hi guys, I have a problem with changing the combo box selected index.

      I load a list of phone types(such as "Home","Office",...) using Remote Object and assign it as a data provider for a combo box.What I need is to select a specific index in the combo but combo.selectedIndex statement doesn't work for the first time, I mean the combo changes its index only if I load the view again.

      I checked different examples, solutions but none of them worked for me!! Can anyone here help me to figure out the problem?

      Here is my Code:



      <mx:Canvas creationComplete="init()"
           <mx:ComboBox id="comboPhone0"
      private var phoneTypeList:ArrayCollection; 
      private function init():void
      private function loadPhoneType():void
           phoneTypeLoaderService.getPhoneType(); //phoneTypeLoaderService is a remote Object to load the phone types
      private function handlephoneTypeLoadResult(ev:ResultEvent):void
           phoneTypeList=ev.result as ArrayCollection; 
              comboPhone.selectedIndex = getComboSelectedIndex("HOME");
      private function getComboSelectedIndex(phoneType:String):int
      var index : int= -1;
      var result : int= -1;
           for each (var pt:PhoneType in phoneTypeList)
                if (pt.type == phoneType)
                          result = index;
                return result;