- Create new Flash File (File->;New or Ctrl + N) and Name it as mouse trailer.
- Draw circle with "gradient fill" like below image.
- Convert this image as an movieclip using Modify->covert to symbol or press F8, choose Movieclip.and name it as obj.
- Make new Movieclip (Insert-> New Symbol or press ctrl+f8) and name it as "glow".
- Drag and drop "obj" movieclip from Library.
- Now we are going to apply some filter effects. open "Filters" window (using window->properties->Filters)
- Apply Glow filter with color #FFFF00, Blur X:12 Blur Y:12, like below image
- Now apply Blur filter with Blur X value 5 , Blur Y value 5 like below image
- Then apply Gradient glow effect like below image.
- Now right click on "glow" movieclip in libraray and click on Linkage, now set Class name as "Element".
- Now press ctrl+N and choose Actionscript File to apply script .
- copy and paste below codes in to this , and save this file in the same location of your fla file.
package digizone{
import flash.display.*;
import flash.events.*;
public class mousetrailer extends MovieClip {
private var count=4;
private var x1=mouseX;
private var y1=mouseY;
public function mousetrailer() {
addEventListener(Event.ENTER_FRAME,showTrailer);
}
public function showTrailer(e:Event) {
if (x1!=mouseX||y1!=mouseY) {
x1=mouseX;
y1=mouseY;
var glower:Element=new Element();
glower.x=mouseX;
glower.y=mouseY;
glower.counter=0;
glower.width+=15;
glower.height+=15;
glower.addEventListener(Event.ENTER_FRAME,fadeIt);
addChild(glower);
}
}
public function fadeIt(evt:Event) {
evt.currentTarget.counter+=1;
//verify if the objects showl start to die
if (evt.currentTarget.counter>count) {
//if it should die we start to fade it and also shrink it
evt.currentTarget.alpha+=-0.03;
evt.currentTarget.width=evt.currentTarget.height-=0.3;
}
//once it has faded completly, we remove the event from the object and also remove the object from the stage
if (evt.currentTarget.alpha<=0)
{
evt.currentTarget.removeEventListener(Event.ENTER_FRAME, fadeIt, false); evt.currentTarget.parent.removeChild(evt.currentTarget);
} } } }
- In mousetrailer.fla , open properties window and type your actionscript class name in Document class .
- Now press ctrl+Enter to run the application.
September 28, 2009
Attractive Mouse Trailer using AS3
Author: Rupa
| Posted at: 6:10 PM |
Filed Under:
Actionscript 3
|
Notice the following sample swf and just move your mouse around the text to view the mouse trailer.