Glow obejct Follow Mouse on click

Date: 11.5.2009, 13:25    Total views: 14869

In this thoroughly explained, detailed flash lesson, I will show you how to create that any object, follow the mouse on click using the Action Script 3. Using this lesson, you will also learn how to convert any object into a Movie Clip Symbol, how to create instance name, how to apply glow filter and action script code on any object and much much more! Let's start!



Example:

Click somewhere and circle shape will follow your mouse click!



Step 1

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set your Flash movie's frame rate to 28 and click ok.



Step 2


Select now the Oval Tool (O) and draw a circle shape like it is shown on the picture below!



Step 3

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



Step 4

After that, go to the Properties Panel (Ctrl+F3) below the stage! Then, select Filters tab from the left side. Click after that on the plus icon and select the Glow filter. Make the adjustments as follows:



Step 5

Select the Selection Tool (V) and click once on the circle (new made movie clip) to select it. After that, while the new made Movie Clip is still selected, go to the Properties Panel. On the left side, You will find the Instance name input field there. Call this Movie Clip "circle_mc". See the picture below!



Step 6

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

Step 7

It's time for action script code, so create a new layer above the layer circle and name it action.

Step 8

Select now the first frame of layer action and go to the Action Script Panel. After that, enter this code inside the actions panel:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;

var xMovement:Tween;
var yMovement:Tween;


function Start():void {
 stage.addEventListener(MouseEvent.CLICK, moveToClick);
}

function moveToClick(event:MouseEvent):void {

 xMovement = new Tween(circle_mc, "x", Back.easeIn, circle_mc.x, mouseX, .7, true);
 yMovement = new Tween(circle_mc, "y", Back.easeIn, circle_mc.y, mouseY, .7, true);
}

Start();

That's it!

Have a nice day!

Download source file (.fla)

  Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!
Share
ShareSidebar