star_mc.onEnterFrame
= function() {
This
creates a function that acts on the movie clip "star_mc"
every time the animation enters a new frame on
the main time line. If there are 30 frames a
second then this function will iterate 30 times
a second performing it's operations.
var
xMouse = _root._xmouse;
var yMouse = _root._ymouse;
This
declares two variables xMouse and yMouse that
store the changing x and y coordinates of the
cursor during run time.
if(Math.abs(xMouse
- this._x) < 1) {
star_mc._x = xMouse;
star_mc._y = yMouse;
}
This
conditional action tells the movieclip to move
to the location of the cursor if the value of
xMouse minus this.x is less than 1. meaning that
if the difference between the cursor position
and the movieclip position is less than 1 the
clip (flash icon) is shunted to its location.
else
{
star_mc._x -= (this._x-xMouse) / 4;
star_mc._y -= (this._y-yMouse) / 4;
}
If the
preceding condition is not met the operation
inside the else brackets is called.
The
operation takes the position of the movie clip
in a given frame then subtracts a quarter of
the difference between the position and the mouse
position
This
creates the easing effect which decelerates the
velocity of the icon as it gets closer to the
mouse position.
the
divisor 4 simply amplified this effect by reducing
this difference that it subtracts from the running
total even further.
|