Home | Contact Us | Store

Mouse Dragging MovieClip with Flash ActionScript 3

With Flash ActionScript 3, this is quite easy to use mouse dragging objects around on the stage.
Your flash player version is too old to see this Flash ActionScript tutorial!

Flash Tutorial Content:

Many Flash application and games require using mouse to drag some objects on the stage. With Flash ActionScript 3, this is quite easy to accomplish this effect.

The complete Flash Movie is shown as above, you may try how it works before you start this tutorial.

Flash ActionScript Codes:

stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseStartDrag);

 

function mouseStartDrag(motion:MouseEvent):void {

// Start dragging when square_mc is pressed
square_mc.startDrag();

// Dispaly message
output_txt.text = "Dragging Square now....";

}

stage.addEventListener(MouseEvent.MOUSE_UP, mouseStopDrag);

 

function mouseStopDrag(motion:MouseEvent):void {

// Stop dragging when square_mc is released
square_mc.stopDrag();

// Display message
output_txt.text = "Square was dragged to: " + "(" + square_mc.x + ", " + square_mc.y + ")";

}

Download Flash Source File:

Flash Source File mouse-4.fla

Remarks:

This Flash ActionScript tutorial shows how to drag objects or movieclip on stage.

Mouse Control Flash ActionScript Tutorial