package components { import mx.collections.ICollectionView; import mx.collections.IList; import mx.controls.ComboBox; import mx.binding.utils.BindingUtils; public class EditableListComboBoxEditor extends EditableListEditor { private var _comboBox:ComboBox; public var labelFunction:Function = null; public var dataProvider:ICollectionView; public function EditableListComboBoxEditor() { super(); } override public function get data():Object { return _comboBox.selectedItem; } override public function update(list:IList):void { if(dataProvider != null) { dataProvider.filterFunction = function(item:Object):Boolean { for each(var xml:XML in XMLList(list)) { if(xml == item) { return false; } } return true; }; dataProvider.refresh(); if(dataProvider.length > 0) { _comboBox.selectedIndex = 0; } } } override protected function createChildren():void { super.createChildren(); _comboBox = new ComboBox(); _comboBox.dataProvider = dataProvider; _comboBox.labelFunction = labelFunction; addChild(_comboBox); } override public function hasContent():Boolean { if(dataProvider == null) return false; return dataProvider.length > 0; } } }