• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Controlling the Movie Clip > Dragging the Movie Clip

Dragging the Movie Clip

Drag-and-drop behaviors give the viewer one of the most direct interactions with the Flash movie. Nothing is more satisfying than grabbing a graphic on the screen, moving it around, and dropping it somewhere else. It’s a natural way of interacting with objects, and it’s easy to give your viewers this experience. Creating a drag-and-drop behavior in Flash involves just two basic steps: creating the movie clip and then assigning ActionScript to an event handler that triggers the drag action.

The usual behavior for drag-and-drop interactivity is for the dragging to begin when the viewer presses the mouse button over the movie clip. Then, when the mouse button is released, the dragging stops. Hence, the action to start dragging is tied to an on (press) or an onPress event handler, and the action to stop dragging is tied to an on (release) or an onRelease event handler. If you use on (press), you assign ActionScript directly to the movie-clip instance. If you use onPress, you assign ActionScript to the root Timeline. Both ways are valid. As you learned in Chapter 4, although it may initially be simpler to assign scripts to the instance, in the long run, as you develop more complicated code, it is better practice to put all your code in one place on the main Timeline.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint