Seek the last cursor position : ArrayCollection Cursor « Data Model « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Data Model » ArrayCollection CursorScreenshots 
Seek the last cursor position
Seek the last cursor position
          
<?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();
            
            var newLength:int=myAC.length;
            myCursor.findFirst("ME");
            var MEMark:CursorBookmark=myCursor.bookmark;
            myCursor.seek(CursorBookmark.LAST);
            var lastItem:String=String(myCursor.current);
            myCursor.seek(MEMark);
            var MEItem:String=String(myCursor.current);
            ta1.text="Start Length: " + oldLength + ". End Length: " + newLength;
            ta1.text+=".\nRemoved " + removedItem;
            ta1.text+=".\nLast Item is " + lastItem;
            ta1.text+=".\nItem at MEMark is " + MEItem;          
        }
        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
1.Get cursor position after removing an item from cursorGet cursor position after removing an item from cursor
2.Create IViewCursor from ArrayCollectionCreate IViewCursor from ArrayCollection
3.Move cursor to nextMove cursor to next
4.Seek last cursor positionSeek last cursor position
5.Find first item through a cursorFind first item through a cursor
6.Find item through cursorFind item through cursor
7.Get bookmark from CursorGet bookmark from Cursor
8.Get current cursor valueGet current cursor value
9.Create cursor from ArrayCollection and Move cursorCreate cursor from ArrayCollection and Move cursor
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.