I have updated the example to include the same trace statements after the 
moveNext() call. This provides the expected result. It seems that the bookmark 
must update at some point later, although this doesn't explain the change 
watcher on the bookmark it's self!

The output from the following is:

currentE, current=Mark
currentE, bookmark=Bobby
currentE, index=0
bookmarkE, current=Mark
bookmarkE, bookmark=Bobby
bookmarkE, index=0
Event, current=Mark
Event, bookmark=Bobby
Event, index=0
Event, index=0
AfterMove, current=Mark
AfterMove, bookmark=Mark
AfterMove, index=1

They should all read Mark...

<?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.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:ICollectionView = new 
ArrayCollection([ "Bobby", "Mark", "Trevor", "Jacey", "Tyler" ]);
                        [Bindable]
                        public var cursor:IViewCursor = 
myArrayCollection.createCursor();
                        
                public function onCreationComplete():void
                {
                        ChangeWatcher.watch( cursor , ["current"] , test , 
true);
                        ChangeWatcher.watch( cursor , ["bookmark","value"] , 
test2 , true);
                        cursor.addEventListener( FlexEvent.CURSOR_UPDATE, 
test3);
                }
                
                public function test( e:FlexEvent ):void
                {
                        // Triggered when the current property of the cursor 
changes            
                        trace('currentE, current='+cursor.current);
                        trace('currentE, bookmark='+cursor.bookmark.value);
                        trace('currentE, 
index='+cursor.bookmark.getViewIndex());
                }
                public function test2( e:FlexEvent ):void
                {
                        // Triggered when the bookmark property of the cursor 
changes
                        trace('bookmarkE, current='+cursor.current);
                        trace('bookmarkE, bookmark='+cursor.bookmark.value);
                        trace('bookmarkE, 
index='+cursor.bookmark.getViewIndex());
                }       
                public function test3( e:Event ):void
                {
                                // Triggered when the cursor dispatches a 
cursor update event
                                trace('Event, current='+cursor.current);
                                trace('Event, bookmark='+cursor.bookmark.value);
                                trace('Event, 
index='+cursor.bookmark.getViewIndex());
                                trace('Event, 
index='+cursor.bookmark.getViewIndex());
                }       
                
                private function _onClick():void
                {
                        cursor.moveNext();
                        trace('AfterMove, current='+cursor.current);
                        trace('AfterMove, bookmark='+cursor.bookmark.value);
                        trace('AfterMove, 
index='+cursor.bookmark.getViewIndex());
                }
                
                ]]>
        </mx:Script>
        <mx:Button label="Move Cursor" click="_onClick()" themeColor="#FAFAFA" 
color="#FFFFFF" horizontalCenter="0" verticalCenter="20"/>
</mx:Application>


Reply via email to