This is a simple tutorial that will teach you how to use the drag and drop system that is common in games such as dress up, tower defense, and any other games where you will need to be dragging objects around the screen.

The first thing you’ll want to do is draw the things that you will be dragging. Draw the object and select it. Now hit F8 and name it whatever you like. You’ll want to be sure you select the Movie clip option though. Now that the object you will be using is on stage, you’ll want to give it an instance name. Click it and give it the whatever instance name you want. I named mine myItem.
Now for the coding part. Go into the code of the button and put this in:

on (press) {
// when your press the buttom
startDrag("");
// start the dragging
}
// end of script
on (release) {
// when you release the mouse button
stopDrag();
// stops the dragging
}
//end of script

Now hit Control+Enter to test your flash and see if it works. You should be able to drag your object around the screen. If it seems a little awkward, try changing the frame rate to a more smooth 20 or 25. You can put this dragging code into as many buttons as you wish. You can even make all your objects on separate layers to choose which objects will appear above or below the others. This is useful for dress up games, in which you will want to have certain objects above other ones.

That’s it for the drag and drop tutorial. This should have you making dress up games in no time. Pretty simple right?

If you liked this post, subscribe to my RSS Feed for more great tips on how to make flash games.

Related posts:

  1. How to Make a Quality Button
  2. How to Disable Tab Button Cheating using AS2
  3. How to Make a Clock in Flash using Actionscript