Adding drag-and-drop functionality


show more Adding drag-and-drop functionality provides you with in-depth training on Developer. Taught by Todd Perkins as part of the ActionScript 3.0 in Flash Professional CS5 Essential Training show less
please wait ...

Adding drag-and-drop functionality

The next step in making the game is to add drag and drop functionality. Now you may already be familiar with adding drag and drop functionality through code snippets. This time we are going to write the code all by hand, so you get some more practice and become more comfortable writing the code. The first thing I am going to do is go in the constructor, and right below where it says, constructor code, I am going to type (MouseEvent.MOUSE_DOWN, and then we'll run a function called drag.

So we will create the drag function now. Go down a few lines below the constructor, so right below that next curly brace, and then type function drag(evt: MouseEvent), type :void, all lowercase and write some curly braces. Now to drag an object, all you need to do is write this one line of code, startDrag, with capital D. Close out the parentheses. Type a semicolon.

Now to test out the drag code, save this file and then test the movie. You should be able to drag any one of these objects if you click your...

Adding drag-and-drop functionality
Video duration: 3m 38s 7h 8m Beginner Updated May 23, 2012

Viewers:

Adding drag-and-drop functionality provides you with in-depth training on Developer. Taught by Todd Perkins as part of the ActionScript 3.0 in Flash Professional CS5 Essential Training

please wait ...