Tutorials with samples for drag and drop in Flash AS3

Asked By 0 points N/A Posted on -
qa-featured

Hi Friends,

I am fresh to Flash AS3 and is studying it by my own.
 
I want few tutorials along with samples for me to understand drag and drop in Flash AS3.
 
Please do the needful for helping me by providing Online tutorial link or send me any free tutorial as an attachment.
 
Thanks.
 
Jones Browns
SHARE
Best Answer by Nelson Mili
Answered By 5 points N/A #189336

Tutorials with samples for drag and drop in Flash AS3

qa-featured

Hello Jones,

I will suggest that you must view and understand this tutorial from https://code.tutsplus.com/tutorials/create-a-drag-and-drop-puzzle-in-actionscript-30–active-2920. It is a simple drag and drop game done in actionscript 3.0.

It this tutorial you’ll learn how to make a draggable movie clip and dropped it off onto your desired position, and the hitTestObject method which is a function in actionscript 3.0.

They are also providing source code and demo, so you’ll not start from scratch.

Happy learning!

Best Answer
Best Answer
Answered By 0 points N/A #189337

Tutorials with samples for drag and drop in Flash AS3

qa-featured

Hello Jones,

This Flash tutorial will teach you about the basic drag and drop in Actionscript 3.0. You will learn how to drag an object around the stage. I have used an image of a sheep as the object to demonstrate the drag and drop functionality.

Drag and drop in AS3

Step 1. Create the object.

Open a new Flash document and create whatever object you wish. Alternatively you could use an image as an object, like I have, by selecting File > Import > Import to stage select your file and click ok.

Step 2. Convert object to symbol.

  • Convert your object into a symbol by pressing F8.
  • Give your symbol an appropriate name, check movie clip and click ok.
  • Select your object using the selection tool (V) and give the instance name: sheep_mc

Step 3. Add the code.

On the timeline insert a new layer called “actions” right click on the first frame and select Actions from the drop down menu.
 

Add the following code:

sheep_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
sheep_mc.addEventListener(MouseEvent.MOUSE_UP, drop);

function drag(event:MouseEvent):void {
sheep_mc.startDrag();
}

function drop(event:MouseEvent):void {
sheep_mc.stopDrag();
}

**The first and second lines of code add event listeners for the mouse up and mouse down events with the parameters drag and drop.

The drag function starts the dragging of the object when the mouse is pressed, and the drop function stops the dragging of the object when the mouse is released.

Step 4. Test your movie.

Test your movie Ctrl + Enter. Now use your mouse to drag and drop the sheep.

Related Questions