Home

Tutorials

Portfolio

Blog

 

Highlights

 

Drag and Drop interfaces

Page 3

1 | 2 | 3 | 4 | 5 | Next

Insert a new layer and select frame 1. Open the Actions Panel (Windows - Actions or F9). Ensure that Script Assist is switched off (press the Script Assist button).

In the Actions Panel type the following line of code:

First line of actionscript

This line of Actionscript adds an event listener to the eyes1 object. An event listener is something that listens out for a specific event occuring. In this case we've told it to listen for a mouse button being pressed down (MouseEvent.MOUSE_DOWN). This line also tells Flash what it should do when it detects this event - it needs to run a function called pickup, which is the next bit of code we will write.

Amend your code as follows, adding the pickup function.

adding the pickup function to the drag and drop game

This function allows the eyes1 object to be dragged around the screen. You can try this out by testing your movie (Control - Test Movie or ctrl-enter).

The next step will add the ability to drop the object when the mouse button is released.

1 | 2 | 3 | 4 | 5 | Next