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

Chapter 14. Controlling Movie Clips Dyna... > DRAGGING AND DROPPING MOVIE CLIP INS...

DRAGGING AND DROPPING MOVIE CLIP INSTANCES

In user interfaces, it’s sometimes useful to add drag-and-drop behaviors to movie clip instances—a term that refers to the process of clicking and dragging movie clip instances around the stage, so that when they’re released (dropped), they’ll perform a set of actions (determined by the location where they’re dropped). The easiest way to conceptualize this type of behavior is by thinking of the trashcan on your computer desktop: If you drag a file over the trashcan and let go of it, that file is deleted; however, if you’re not over the trashcan when you let go, you’ve simply moved the file icon.

The most common way to create drag-and-drop items in Flash is by using _droptarget or hitTest() . Checking the _droptarget property of a movie will return the path in slash syntax to the highest movie clip instance that the currently dragged movie clip instance is over. Using the hitTest() method, you can determine whether the bounding box of one instance is touching the bounding box of another (for more on this, see Lesson 9, Using Conditional Logic) and take action accordingly. The hitTest() method is used more frequently because it’s more versatile than the _droptarget property.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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