Insert value to ComboBox through Cursor
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData();">
<mx:Script>
import mx.collections.*;
public var myArray:Array = [{label:"A", data:"1"},
{label:"B", data:"2"},
{label:"C", data:"3"}];
[Bindable]
public var myAC:ArrayCollection;
public var myCursor:IViewCursor;
public function initData():void {
myAC = new ArrayCollection(myArray);
}
public function testCollection():void {
data.myCursor=myAC.createCursor();
ta1.text="cursor is at: " + myCursor.current.label;
myCursor.insert({label:"ME", data:"Augusta"});
ta1.text+="\n cursor is at: " + myCursor.current.label;
}
</mx:Script>
<mx:ComboBox id="myCB" rowCount="7" dataProvider="{myAC}" />
<mx:TextArea id="ta1" height="75" width="350" />
<mx:Button label="run test" click="testCollection();" />
</mx:Application>
Related examples in the same category