Toxiclab.org

Drag the glow image using the AS3

20.7.2009, 16:47
Submited in: Flash | Total Views: 8489

This detailed action script 3 lesson made for Flash will teach you how to drag and drop any image. Using this lesson, you will also learn how to import any image into a flash stage, how to convert it into a Movie Clip Symbol, how to apply flash filters on it, how to create action layer and apply action script code on it and much more!

Example:

Drag the image below using the mouse cursor!




Step 1

First, find any image which you like to use for this lesson.



Step 2


Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 32 and click ok.

Step 3

Call the current layer image. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import any image into a flash stage.

Step 5

While the image is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 6

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip image_mc. See the picture below!



Step 7

After that, select the Selection Tool (V) and click once on the image to select it. Then, go to the Properties Panel (Ctrl+F3) below the stage. After that select Filters tab from the left side, click on the plus icon and select the Glow filter. Make the adjustments as follows:



Step 8

Create a new layer above the layer image and name it action. After that, select the first frame of layer action and go to the Action Script Panel (F9). Then, this code inside the actions panel:

image_mc.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
image_mc.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
function onStartDrag(evt:MouseEvent):void {
evt.target.startDrag();
}
function onStopDrag(evt:MouseEvent):void {
evt.target.stopDrag();
}

We're done now!

Test your movie and enjoy!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials