Insertion on the Array and ArrayCollection
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600"
initialize="sortAC()">
<mx:Script>
import mx.collections.*;
public function sortAC():void {
var sortA:Sort = new Sort();
sortA.fields=[new SortField("label")];
myAC.sort=sortA;
myAC.refresh();
}
public function addItemToMyAC():void {
myAC.addItem({label:"MD", data:"Annapolis"});
}
</mx:Script>
<mx:ArrayCollection id="myAC">
<mx:Array id="myArray">
<mx:Object label="a" data="A" />
<mx:Object label="b" data="B" />
<mx:Object label="c" data="C" />
</mx:Array>
</mx:ArrayCollection>
<mx:HBox width="100%">
<mx:ComboBox id="cb2" rowCount="10" dataProvider="{myArray}" />
<mx:ComboBox id="cb1" rowCount="10" dataProvider="{myAC}" />
<mx:Button id="b1" label="Add MD" click="addItemToMyAC();" />
</mx:HBox>
</mx:Application>
Related examples in the same category