Add data to ComboBox when click the button
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData()">
<mx:Script>
import mx.collections.*;
[Bindable]
public var stateArray:ArrayCollection;
public function initData():void {
stateArray=new ArrayCollection(
[{label:"AL", data:"aa"},
{label:"AK", data:"BB"},
{label:"AR", data:"CC"}]);
}
</mx:Script>
<mx:ComboBox id="myComboBox" dataProvider="{stateArray}" />
<mx:Button label="Add AZ" click="myComboBox.dataProvider.addItem({'label':'Z','data':'ZZ'});" />
</mx:Application>
Related examples in the same category