In this example you can see how we can drag and drop the component from one place to another.
In this example you can see how we can drag and drop the component from one place to another.In this example you can see how we can drag and drop the
component from one place to another. There are the three classes of drag and
drop operation:
1. DragManager: It manages the drag and drop operation using doDrag() method.
2. DragSource: It contains the data which is dragged.
3. DragEvent: It represent the drag and drop events.
In this example we will drag and drop a Button control in a Panel from one place
to another.
|
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s=" library://ns.adobe.com/flex/spark"xmlns:mx=" library://ns.adobe.com/flex/mx"minWidth=" 955" minHeight="600"><![CDATA[ import mx.managers.DragManager;{ dragSource.addData(dragInitiator, "button");DragManager.doDrag(dragInitiator, dragSource, event); } private function dragEnterHandler(event:DragEvent):void {{ DragManager.acceptDragDrop(Panel(event.currentTarget)); } } private function dragDropHandler(event:DragEvent):void {Button(event.dragInitiator).x = Panel(event.currentTarget).mouseX; Button(event.dragInitiator).y = Panel(event.currentTarget).mouseY; } ]]> width=" 386" height="282"chromeColor=" #555555"color=" #CCCCCC"dragEnter="dragEnterHandler(event);" dragDrop="dragDropHandler(event);" > <s:Button id="btn" label="Drag Button"mouseMove="mouseMoveHandler(event)" /></s:Application> |

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.