I see there was another long thread about this problematic component back in
October (Dan Pride)

I don't see why this shouldn't work:

      <mx:ComboBox id="dateRangePresetCombo"
          dataProvider="{this.availableRanges}"

selectedIndex="{this.computeSelectedDateRangeIndex(this.selectedDateRangePreset,
this.availableRanges)}"
          rowCount="{availableRanges.length}"
          labelFunction="labelFunction"
          change="onDateRangePresetSelected(event)" />

where selectedDateRangeIndex() scans the available ranges, and
this.selectedDateRangePreset and this.availableRanges are bindable. But it
doesn't. When the component is first created, the combobox appears with the
first item selected (sometimes).

I believe Dan's workaround involved callLater(). I just had some success
with the following:

      <mx:ComboBox id="dateRangePresetCombo"
          dataProvider="{this.availableRanges}"

selectedIndex="{this.computeSelectedIndex(this.selectedDateRangePreset,
this.availableRanges)}"
          rowCount="{availableRanges.length}"
          labelFunction="labelFunction"
          added="onComboBoxCreation(event)"
          change="onDateRangePresetSelected(event)" />

where on onComboBoxCreation() calls computeSelectedIndex() and sets
dateRangePresetCombo.selectedIndex.

Doing it  on creationComplete rather than "added" results in flicker as the
item changes from item1, but using the added event seems to do the trick.

I'm pretty sure there's a bug in ComboBox. Probably not invalidating
properties or the display list when it should.

Hope this helps someone, and please set me straight if I'm wrong.

Reply via email to