I have a view with two states, normal and expanded. In the expanded
state additional controls are visible.

I do an mx:AddChild of an MXML component, lets call it
view:MyControls. MyControls contains a view:PresetSelector, which
contains a subclass of ComboBox, StringComboBox, which is reminiscent
of Alex's FindSelectedItemComboBox:

                override public function set selectedItem(value:Object):void {
                        selectedIndex = findSelectedIndex(value);
                }

The ComboBox subclass works fine in many different areas of the
application. However, with the bindings as below, when you collapse
and re-expand the view after changing the combobox selection, the new
selection is not shown, even though the model was updated. Rather the
previous (default) selection is shown.

MyControls.mxml

                                <view:PresetSelector id="presetSelector"
                                                
choiceProvider="{model.presetChoices}"
                                                
selectedPreset="{model.selectedPreset}"/>
PresetSelector.mxml:

        <view:StringComboBox id="presetCombo"
                dataProvider="{choiceProvider}"
                selectedItem="{selectedPreset}"
                rowCount="{choiceProvider.length}"
                labelFunction="presetLabel"
                change="usePreset(event)"/>     

 I've stepped through Combobox/Base to the point when
invalidateDisplayList is called, and can only conclude that that
doesn't work because the AddChild is still in progress. Incidentally,
it appears that MyControls is recycled rather than reconstructed on
successive AddChild calls.

One workaround I tried earlier used the updateComplete event, but that
seemed hackish. Perhaps I should just show/hide/includeInLayout the
controls, rather than Add/Remove them.

I'm tempted to accuse ComboBox of having a bug, since I don't have
similar issues with checkboxes and radio buttons, but if someone sees
a flaw in my approach, please let me know.

Reply via email to