im trying to create an animation that features a movie clip following the mouse cursor. the further the cursor is, the faster the movie clip moves towards it.
however, i do NOT want the MC to go all the way to the cursor.
rather, id like to have it contained within a specific area (meaning it can only travel so far towards the mouse cursor, before it is completely halted).
the current code i have (which does not stop the MC at a point, like i'd like it to) is as follows:
Code:
onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/10;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
//y movement
my=_root._ymouse;
if (my<_y) {
dy=_y-my;
}
else {
dy=my-_y;
}
moveSpeedy=dy/10;
if (my<_y) {
_y=_y-moveSpeedy;
}
else {
_y=_y+moveSpeedy;
}
}
i have the action applied to the MC.
how can i alter it to get the MC to stop at a certain point?
thanks,
i'm not new to action scripting. i'm just bad at it.
instead of a "deadzone" area, tho (where the following object is always X amount of pixels from the mouse) ...
im looking moreso for a containment area -- so that no matter where the mouse is moving to (or how far its moving away) the movie clip following the cursor always stays in its little, invisible "cage".
additionally, the MC has to still be responsive to the cursor. for example: the MC will still move up if the mouse does, even tho it cant move to the right anymore
that make sense?
i'm not new to action scripting. i'm just bad at it.