<?xml version="1.0" encoding="iso-8859-1"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp();" backgroundAlpha="0"> <mx:Script> <![CDATA[ import mx.collections.*; [Bindable] public var cursor:IViewCursor; private function initApp():void { cursor = col.createCursor(); } private function seekFirst():void { cursor.seek(CursorBookmark.FIRST); lbl.text = cursor.current.name + " (" + cursor.current.abbreviation + ")"; } private function seekLast():void { cursor.seek(CursorBookmark.LAST); lbl.text = cursor.current.name + " (" + cursor.current.abbreviation + ")"; } private function forwardIteration():void { if (cursor.afterLast) { cursor.seek(CursorBookmark.FIRST); } lbl.text = cursor.current.name + " (" + cursor.current.abbreviation + ")"; cursor.moveNext(); } private function backwardsIteration():void { if (cursor.beforeFirst) { cursor.seek(CursorBookmark.LAST); } lbl.text = cursor.current.name + " (" + cursor.current.abbreviation + ")"; cursor.movePrevious(); } ]]> </mx:Script> <mx:ArrayCollection id="col"> <mx:source> <mx:Array> <mx:Object abbreviation="IAH" name="Houston"/> <mx:Object abbreviation="BOS" name="Boston"/> <mx:Object abbreviation="MHT" name="Manchester"/> <mx:Object abbreviation="JAX" name="Jacksonville"/> <mx:Object abbreviation="CVG" name="Cincinatti"/> <mx:Object abbreviation="ATL" name="Atlanta"/> <mx:Object abbreviation="CDG" name="Paris"/> <mx:Object abbreviation="JFK" name="New York"/> <mx:Object abbreviation="LAX" name="Los Angeles"/> <mx:Object abbreviation="HND" name="Tokyo"/> </mx:Array> </mx:source> </mx:ArrayCollection> <mx:DataGrid dataProvider="{col}" width="450"/> <mx:Tile> <mx:Button click="seekFirst();" label="seek first" width="140" /> <mx:Button click="seekLast();" label="seek last" width="140" /> <mx:Button click="forwardIteration();" label="forward iteration" width="140" /> <mx:Button click="backwardsIteration();" label="backward iteration" width="140" /> </mx:Tile> <mx:Label id="lbl" width="300"/> </mx:Application>
|