1 Reply Latest reply on Oct 31, 2009 5:07 AM by paul.williams

    Notification after Drag source has changed


      I am trying to execute some code after the data has been changed to a "drag source" control.  For instance, when an item is dragged from a TileList, I can execute some code when I get a "dragdrop" event on the destination control.  But at that time, the source control data provider has not yet been changed to have the item removed.  I tried to execute code on the "dragComplete" event, but the source control item had not been removed yet.  I seem only to get drag and drop events on the destination control and not the source control. How can I get an event when the data provider has changed on the source control in a drag/drop operation?



        • 1. Re: Notification after Drag source has changed
          paul.williams Level 4

          The update to the dataProvider is performed in the dragCompleteHandler of your source list control (in source view of Flex Builder do Ctrl+Shift+T, open ListBase and search for dragCompleteHandler). The problem you are seeing is probably due to your own event handler running before the List's default event handler. This is by design, because it allows you to prevent the default behaviour of the List.


          One solution would be to extend List and override dragCompleteHandler to dispatch a further event after the dataProvider has been updated:


          protected function dragCompleteHandler(event:DragEvent):void


               super.dragCompleteHandler( event );


               dispatchEvent( new Event( "dragUpdateComplete" ) );



          Another possible solution (that I have never tried) would be to alter the priority of your own event listener to cause it to fire after the List's event handler. You cannot set the priority of the event handler in MXML, so you'll need to set-up the listener in ActionScript. Here's more on priorities, you'll probably need to set a negative priority: