I have found a work around for this problem (which may be a bug). It seems that the CURSOR_UPDATE event is dispatched before the cursor has fully updated,. This means the bookmark is still pointing at the previous item. This is a big problem if you want to use the bookmark to see if there is a next or previous item using the bookmark.getViewIndex() method.
One work around would be to dispatch your own change event when ever you update a cursor. This can be a bit of a nightmare, and not very robust incase someone implements new code and doesn't do it. Instead I have created a fix at the other end of the process, and something that shouldn't break if the bug is resolved. In your event handler you can detect if the current item is the same as the bookmark's current item. If not then you can seek the cursor to the current position again, by which point the bookmark will have been updated and pointing to the correct place :) Hope this helps someone else, as I have wasted far too much time on it! Rob Full working example below: =============================== <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#333333" creationComplete="onCreationComplete()" width="100%" height="100%" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.collections.CursorBookmark; import mx.collections.SortField; import mx.collections.Sort; import mx.events.PropertyChangeEvent; import mx.events.FlexEvent; import mx.collections.ArrayCollection; import mx.collections.IViewCursor; import mx.collections.ICollectionView; import mx.binding.utils.ChangeWatcher; import mx.controls.Alert; [Bindable] public var myArrayCollection:ArrayCollection = new ArrayCollection(); [Bindable] public var cursor:IViewCursor = myArrayCollection.createCursor(); public function onCreationComplete():void { for( var i:int=0; i<10; i++ ) { var obj:Object = new Object(); obj.name = i+'name'; myArrayCollection.addItem(obj); } cursor.addEventListener( FlexEvent.CURSOR_UPDATE, test); var sort:Sort = new Sort(); sort.fields = [new SortField('name',true,true)]; myArrayCollection.sort=sort; myArrayCollection.refresh(); cursor.seek(CursorBookmark.FIRST); } public function test( e:Event ):void { // Triggered when the cursor dispatches a cursor update event trace('\n\nEvent, current='+cursor.current.name); trace('Event, bookmark='+cursor.bookmark.value.name); // If the bookmark hasn't been updated yet, then seek to the current position // This will cause this event handler to be called again, by which point the current bookmark will have been updated if( cursor.current != cursor.bookmark.value) { cursor.findFirst(cursor.current); } } private function _onClick():void { cursor.moveNext(); trace('AfterMove, current='+cursor.current.name); trace('AfterMove, bookmark='+cursor.bookmark.value.name); } private function _onClick2():void { cursor.movePrevious(); trace('AfterMove, current='+cursor.current.name); trace('AfterMove, bookmark='+cursor.bookmark.value.name); } ]]> </mx:Script> <mx:Button label="Move Cursor" click="_onClick()" themeColor="#FAFAFA" color="#FFFFFF" horizontalCenter="0" verticalCenter="20"/> <mx:Button label="Move Cursor back" click="_onClick2()" themeColor="#FAFAFA" color="#FFFFFF" horizontalCenter="0" verticalCenter="40"/> </mx:Application>

