Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : Follow the mouse


htmlmaniac
9/16/2004 11:14:13 PM
kglad
9/17/2004 1:10:24 AM
put the following code in some kind of loop:

mc._x=_xmouse;
mc._y=_ymouse;

if you want the movieclip to move to the mouse's position with a delay or
bounce or some other kind of effect different coding will be needed.
abeall
9/17/2004 1:17:34 AM
using MX-04? I'm not but you could take advantage of the tween() class

_root.onMouseMove = function(){
mouseFollower_movieClip.tween(move _x and _y to _xmouse and _mouse, with
bounce or elastics)
}

I dont know the params for the tween() class, but you could look it up.
kglad
9/17/2004 1:40:41 AM
abeall
9/17/2004 2:10:09 AM
haha

apparently theres no documentation for it at all in Flash MX 2004 - maybe they
were smoking crack when they made it!


http://www.actionscript.org/tutorials/advanced/Tween-Easing_Classes_Documented/i
ndex.shtml

Maybe I misunderstand the technicalities of it, but it sounds neat :)

And the one someone made, compatable with AS1.0
http://laco.wz.cz/tween/
kglad
9/17/2004 3:29:02 AM
there's no documentation in flash, but there's plenty of info on the web. i
checked it out, customized and have it working like a charm. it's awkward to
use the way it's setup in flash but i tweaked it so it's easy for me to use. i
have:

import mx.transitions.easing.*;
import mx.transitions.Tween;
EC = [Strong, Back, Elastic, Regular, Bounce, None];
ET = ["easeIn", "easeOut", "easeInOut", "easeNone"];
function tweenMC(mc:MovieClip, property, easeType:Function, begin, end,
duration_or_frames, useSeconds):Void {
var myTween:Tween = new Tween(mc, property, easeType, begin, end,
duration_or_frames, useSeconds);
}

and to use, for example:

tweenMC(myMC, "_y", EC[1][ET[2]], 0, 333, 3, 1);
AddThis Social Bookmark Button