all groups > flash actionscript > february 2004 >
You're in the

flash actionscript

group:

Please help with follow mouse!


Please help with follow mouse! Maurice.Hason
2/17/2004 10:49:51 PM
flash actionscript: Hello
I have a menu with a movie clip that slides following the mouse, up and down
The code looks as follows

onClipEvent (load)
_y = 0
speed = 8

onClipEvent (enterFrame)
endY = _root._ymouse
_y += (endY-_y)/speed


I need to make this movie clip follow the mouse only within a specified area
on the stage and not the entire stage, and when the mouse exits the specified
area, the movie clip should return back to a default position on the stage

I would appreciate any help to accomplish this
Thank
Mauric
Re: Please help with follow mouse! asiabackpacker
2/17/2004 11:10:30 PM
the easiest way would probably be to enclose your action in an if statement,
like this

if (_root._xmouse >= leftBorder &&
_root._xmouse <= rightBorder &&
_root._ymouse >= topBorder &
_root._ymouse <= bottomBorder)


} else {_y = homeY;

then, obviously set the variables, topBorder, rightBorder, etc... to whatever
you want
let me know if you still have question
Re: Please help with follow mouse! Maurice.Hason
2/17/2004 11:37:18 PM
this works great, exactly as expected, just one small problem
when the mouse exits the area, the movie clip jumps back to the homeY
position, and I would like to make is slide back smoothly, just the same way as
it slides when following the mouse

thanks for your help!
AddThis Social Bookmark Button