Track | mouse | effects
This tutorial is fully implemented using the Flash Action Script command! Using Flash drawing we already know! This tutorial will be for you to review the Flash ActionScript drawing function!
This tutorial makes the mouse follow the effect is very special, is some with the color of the shape of the transformation of some graphics.
First look at the effect. (Use the mouse to move in the animation can see the effect)
Click here to download the source file
Production methods.
First create a new document, and then press Ctrl+j to modify the property.
Then put the following code in the first frame.
/* Define 5 Global Variables * *
var time:number = 0;
var timemin:number = 100;
var alphadrop:number = 2;
var growby:number = 2;
var rotatebymax:number = 10;
/* Transform radians function * *
function Deg2rad (degrees:number): number {
return degrees * MATH.PI/180;
}
/* Returns a number between the maximum and the minimum value * *
function Randrange (Min:number, Max:number): number {
var randomnum:number = Math.floor (Math.random () * (Max-min + 1)) + min;
return randomnum;
}
/* draws a rule polygon, setting the color, size, radius */
Function Drawpoly (Sides:number, Color:number, Radius:number): MovieClip {
var depth:number = _root.getnexthighestdepth ();
var poly_mc:movieclip = _root.createemptymovieclip ("poly" + depth, depth);
var unitangle = Deg2rad (360/sides);
Poly_mc.beginfill (color);
Poly_mc.moveto (radius, 0);
for (var i:number = 1; i < sides i++) {
var turn:number = Unitangle * i;
var dx:number = Math.Cos (Turn) * RADIUS;
var dy:number = Math.sin (Turn) * RADIUS;
poly_mc.lineto (dx, dy);
}
Poly_mc.endfill ();
return POLY_MC
}
/* Initialize a movie clip * *
function Initpoly (): Void {
this._x = _xmouse;
this._y = _ymouse;
This._xscale = This._yscale = 0;
This.rotateby = Randrange (-rotatebymax, Rotatebymax);
This.onenterframe = function (): Void {
This._xscale = This._yscale + = Growby;
This._alpha-= Alphadrop;
This._rotation + = This.rotateby;
if (This._alpha < 0) {
This.removemovieclip ();
}
};
}
/* Main program * *
OnMouseMove = function (): Void {
if (Gettimer ()-time > Timemin) {
Initpoly.apply (Drawpoly (Randrange (3), Randrange (0, 0xFFFFFF), 100));
Time = Gettimer ();
}
};
Finally Press Ctrl+enter test! See how it works? Isn't it amazing? Learn Flash's ActionScript quickly! Very impressive!