PDA

View Full Version : Anyone know?


Phil_Collins
01-18-2006, 06:08 PM
Hi Guys. Does anyone know how they have done the effect on this site http://www.madrid2milyalgo.com/ where the different MC's move around in accordance to the movement of the mouse? ie. move the mouse left and the mc moves right etc.

I've seen this effect loads but dont know how its done. Can anyone point me to a tutorial that might help or something?

Cheers. Phil

Phil_Collins
01-18-2006, 06:39 PM
Anyone?

Scottae
01-18-2006, 07:29 PM
var w:Number = 100;
var delay:Number = 10;
var mc:MovieClip = _root.createEmptyMovieClip ("mc", _root.getNextHighestDepth ());
mc.beginFill (0xFF0000, 100);
mc.lineTo (w, 0);
mc.lineTo (w, w);
mc.lineTo (0, w);
mc.lineTo (0, 0);
mc.endFill ();
mc.onEnterFrame = function ()
{
var xdif:Number = Stage.width - _xmouse - this._x;
var ydif:Number = Stage.height - _ymouse - this._y;
this._x += xdif / delay;
this._y += ydif / delay;
};