mercredi 1 mars 2017

Actionscript 3 filter items out of combobox

So I have a combobox that should work as follows:

  1. Click dropdown
  2. Choose an item
  3. item is moved into another list
  4. Item can no longer be found in first combobox dropdown

So I created a combobox like:

    <s:ComboBox
            id="cbox"
            labelFunction="labels"
            dataProvider="{objects}"
            change="addFilter()"
            restrict="a-zA-Z0-9\-,_"
            width="100%"
            maxChars="32"
            prompt="add filter"
    />

My issue stems from calling objects.refresh(), as it fails in the list.as file (AS library) at the line dataGroup.removeEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteListenerA);, where the dataGroup is null.

My filter function on the objects ArrayCollection is something like:

private function filterEcus(item:Object):Boolean {
     for each (var i:Object in secondList) {
        if (i.property == item.property) {
            return true;
        } else {
            return false;
        }
    }
    //should not reach this
    return true;
}

I call the refresh at the end of the change handler.

Aucun commentaire:

Enregistrer un commentaire