Find first item through a 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 = ["AZ", "MA", "MZ", "MN", "MO", "MS"];
[Bindable]
public var myAC:ArrayCollection;
public function initData():void {
myAC = new ArrayCollection(myArray);
var myCursor:IViewCursor=myAC.createCursor();
var oldLength:int=myAC.length;
var removedItem:String=String(myCursor.remove());
myCursor.moveNext();
myCursor.insert("AAAAA");
myCursor.seek(CursorBookmark.LAST, 1);
myCursor.insert("BBBBB");
var sort:Sort = new Sort();
myAC.sort=sort;
myAC.refresh();
if (myCursor.findFirst("MZ") && !myCursor.findFirst("MI")) {
myCursor.remove();
myCursor.insert("MI");
}
}
public function sortICV():void {
}
public function resetView():void {
myArray = ["AZ", "MA", "MZ", "MN", "MO", "MS"];
myAC = new ArrayCollection(myArray);
ta1.text="Reset";
}
</mx:Script>
<mx:ComboBox id="myCB" rowCount="7" dataProvider="{myAC}" />
<mx:TextArea id="ta1" height="75" width="300" />
<mx:HBox>
<mx:Button label="Update View" click="initData();" />
<mx:Button label="Sort View" click="sortICV();" />
<mx:Button label="Reset View" click="resetView();" />
</mx:HBox>
</mx:Application>
Related examples in the same category