Populating a ComboBox control using variables
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initData();">
<mx:Script>
import mx.collections.*
[Bindable]
private var COLOR_ARRAY:Array = [{label:"Red", data:"#FF0000"},
{label:"Green", data:"#00FF00"},
{label:"Blue", data:"#0000FF"}];
[Bindable]
public var colorAC:ArrayCollection;
private function initData():void {
colorAC = new ArrayCollection(COLOR_ARRAY);
}
</mx:Script>
<mx:ArrayCollection id="stateAC" source="{COLOR_ARRAY}" />
<mx:ComboBox dataProvider="{colorAC}" />
</mx:Application>
Related examples in the same category