1. Home
  2. Computing & Technology
  3. Animation

Flash Animation 19: Drag and Drop ActionScripting Commands

By Adrien-Luc Sanders, About.com

3 of 5

Starting Mouse Dragging

Now for the next step, I've switched to Expert mode (the blue arrow in the upper right hand corner), because after I add another command, I'm going to need to edit it.

The command to start dragging an element can be found by expanding Actions->Movie Clip Control; the fifth option down is the startDrag command, which causes the dragging action to start (hence the name "startDrag"). Double-clicking on this will insert the following code:

startDrag ( ) ;

Like other Flash commands, the parentheses are where you would put any sub-parameters for the command to define its behavior. We don't need to do that for this; we're just doing a simple drag and drop. All we need to do is define what the drag command will affect, and for that we're going to actually type in an addition to the code:

this.startDrag ( ) ;

If you remember from past lessons, this sort of structure places the object to be affected before the command, separated by a period. The this parameter is a common parameter used to refer to the object that you're assigning an action to; in essence, at the moment you are "inside" the Hat object, and so by referring the startDrag command to this you are telling it to act on the object that it is inside of. This can work with nearly any object.

Explore Animation
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Flash Animation 19: Drag and Drop ActionScripting Commands

©2009 About.com, a part of The New York Times Company.

All rights reserved.