Creating Basic Drag-and-Drop Interactivity
Drag-and-drop functionality is made possible by the startDrag() and stopDrag() methods of movie clips. Because these are movie clip methods, the only objects you can make draggable are, well, movie clips. Remember, just because you have to use a movie clip symbol for something doesn't mean it must include an animation. It could be a single object on a single frame, which is what we'll use in this task.
1. | Open dante.flaeither the version you completed from Lesson 11 or the one in this lesson's Start folder. Click Frame 10 in any layer to see the lower half of the Inferno map . |
If you take a moment to click on each of the drag-and-drop monsters, you'll see that they're all there, but they're simple bitmap graphicsnot movie clips.[View full size image]


2. | Select Chiron the centaur and press F8 to convert the bitmap graphic to a symbol. In the Convert to Symbol dialog, name the symbol chiron , set its Behavior to Movie Clip, set its Registration to the top-left corner (if necessary), and click OK . |
By converting the bitmap graphic to a movie clip, you enable the drag capability. At this point, you can't drag the movie clip, but the potential is there.In naming it chiron, remember that you're naming the symbol itself, as it will be listed in the Library. You are not naming the instance, even though the graphic is now in a movie clip instance on the stage.By setting its registration point to the upper-left corner, you make it easier to position the graphic later.[View full size image]

3. | Repeat Step 2 for the remaining three monsters. Name the second monster from the left lucifer , then geryon , and finally fury . The Registration for all the monsters should be the upper-left corner . |
At this point, you've made it possible for each of the monsters to be dragged.
4. | In the Property inspector, give each of the monster movie clips an instance name. Left to right, the instance names should be as follows: chiron_mc, lucifer_mc, geryon_mc, and fury_mc . |
Giving these movie clips instance names enables you to make them draggable and lets other parts of the movie communicate with each instance.[View full size image]

5. | Click Frame 10 of the actions layer, press F9 if necessary to open the Actions panel, and add the following code at the bottom of the existing script: // Creates Chiron drag and drop functionality |
Even if you haven't used the startDrag() and stopDrag() actions before, you can probably read this script without any trouble. The keyword this simply refers to the current timelinein this case, the chiron_mc movie clip instance. The two event handlers cause the script to activate when the user presses the mouse over the movie clip and then releases the mouse.[View full size image]

6. | Press Ctrl+Enter (Windows) or Command+Return (Macintosh) to test the movie. Click the Down button to get to Lower Hell. Try dragging and dropping Chiron . |
The script is all you need to make the character fully draggable. At this stage the interaction is primitive, because nothing happens when you drag and drop the character, and there's nowhere special to drop it. Still, you can see how easy it is to add this sort of functionality to a movie clip.

7. | Return to the main movie and save your file . |
Now it's time to make this simple interaction more meaningful.For now, don't bother adding the same script for the other three monsters. The script is about to get more complex, so you should wait until you perfect it, and then copy and paste the script to add it to the other monsters. (You'll tweak each copied script to customize it for its specific monster.)