Image drag effect

The following example illustrates how to drag an image.



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
<![CDATA[

private function onMouseDown (): void
{
var rec:Rectangle =
new Rectangle(0, 0, mainCanvas.width, mainCanvas.width);
imageAnimation.startDrag(false, rec);
}

private function onMouseUp (): void
{
imageAnimation.stopDrag();
}

]]>
</mx:Script>

<mx:Canvas id="mainCanvas"
width="100%"
height="100%"
verticalScrollPolicy="off"
horizontalScrollPolicy="off">

<mx:Image
id="imageAnimation"
source="@Embed('assets/flash_icon.png')"
mouseDown="onMouseDown()"
mouseUp="onMouseUp()">
</mx:Image>

</mx:Canvas>

</mx:Application>






Click on the image and drag it anywhere on the canvas

 

Labels