I’m using a lens flare…that follows the user’s mouse…but I want to animate it so that it goes from the left side of the screen to the right.

It currently uses…

flare._x = _xmouse;

flare._y = _ymouse;

and it just cycles on this using…

prevFrame();

play();

What would be the best way to animate it…?

Thanks.

and this is how it works…

var x;

var y;

var angle;

var radius;

var big_alpha = 0;

function placeObject (object, expand)

{

// The higher expand is set, the more it will stretch-out from the center

// as the light moves from the center.

object._x = (radius * expand) * Math.cos(angle);

object._y = (radius * expand) * Math.sin(angle);

}

and on the next frame…

radius = Math.sqrt(_x*_x+_y*_y);

angle = Math.atan(_y/_x);

// Correct angle for quadrant.

if (_x < 0) angle = (Math.PI) + angle;

burst1._x = x;

burst2._y = y;

placeObject(burst2, 1);

placeObject(burst3, 0.5);

placeObject(burst4, 1.8);

placeObject(burst5, 0.6);

placeObject(burst6, 1.5);

placeObject(burst7, -0.4);

placeObject(burst8, 1.6);

placeObject(burst9, -0.2);

// Closer to the center, the more alpha there is.

big_alpha = 100 - radius;

if (big_alpha < 0) big_alpha = 0;

bigburst._alpha = big_alpha;