Mega Code Archive

 
Categories / Flex / Data Model
 

Create cursor from ArrayCollection and Move cursor

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">     <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" creationComplete="init()">     <mx:Script>                      import mx.collections.SortField;             import mx.collections.Sort;             import mx.collections.IViewCursor;             import mx.collections.CursorBookmark;             import mx.collections.ArrayCollection;             [Bindable]             private var coll:ArrayCollection;             [Bindable]             private var cursor:IViewCursor;             private function init():void {                 coll = new ArrayCollection([{city:"A", state:"C", region:"E"},                                               {city:"B", state:"D", region:"F"}]);                 cursor = coll.createCursor();             }                 </mx:Script>     <mx:Label text="{cursor.current.city}"/>     <mx:Button click="cursor.moveNext()" label="Next"/>     <mx:Button click="cursor.movePrevious()" label="Previous"/> </mx:VBox> </mx:Application>