Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

Chapter 7. Using Arrays and Loops in Act... > Generating drag-and-drop functionali...

Generating drag-and-drop functionality

You can easily turn movie clips into draggable objects in ActionScript using two built-in methods called startDrag() and stopDrag(). You will use these methods to give your user drag-and-drop control of the basket_mc clip.

Using the startDrag() and stopDrag() methods

You can call the startDrag() method to make any MovieClip instance (or sprite) draggable and the stopDrag() method to make it no longer draggable. For instance, you may want to make an object draggable when the user presses the mouse button on it, and to make the dragging stop when the mouse button is released. This behavior is what most people think of as dragging and dropping an object. You will add event listeners for the MOUSE_DOWN and MOUSE_UP events to add this functionality to the basket_mc clip.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial