Mouse follow in a contained area

I’ve managed to figure out the action scripting for a mouse follow along a Y axis. I want to limit the follow to just a certain contained area on the page. What scripting would I use for that? Thanks


add an if statement to limit the area. post if you need more indepth answers.

yeah, i’m a little slow on the uptake…

I downloaded a certain mouse follow script from virtual fx:…020109.php

The action scripting that goes along with it is:

thisY = getProperty("/drg1", _y);
spY = getProperty("/spin1", _y);
difY = thisY-spY;
yStp = difY/10;
setProperty("/spin1", _y, Number(spY)+Number(yStp));

Where in this party of fun would I place the if? Thanks for the quick reply :slight_smile:


Ok, well I’m about to throw a grenade into your party. That tutorial was made in Flash 4 and it used depreciated code (old code) I fixed the code so it is updated:

&nbsp &nbsp &nbsp &nbsp friction = 8
&nbsp &nbsp &nbsp &nbsp nXdiff = _root._xmouse - _x
&nbsp &nbsp &nbsp &nbsp nYdiff = _root._ymouse - _y
&nbsp &nbsp &nbsp &nbsp _x += nXdiff/friction
&nbsp &nbsp &nbsp &nbsp _y += nYdiff/friction

this code would go right on the MovieClip. Now with the restriction it would look like:

onClipEvent (load) {
&nbsp &nbsp &nbsp &nbsp friction = 8;
onClipEvent (enterFrame) {
&nbsp &nbsp &nbsp &nbsp nXdiff = _root._xmouse - _x;
&nbsp &nbsp &nbsp &nbsp nYdiff = _root._ymouse - _y;
&nbsp &nbsp &nbsp &nbsp if (_root._xmouse >= 50 && _root._xmouse <= 300) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _x += nXdiff / friction;
&nbsp &nbsp &nbsp &nbsp }
&nbsp &nbsp &nbsp &nbsp if (_root._ymouse >= 50 && _root._ymouse <= 300) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _y += nYdiff / friction;
&nbsp &nbsp &nbsp &nbsp }

if you have any specific questions, ask away…

Everything worked out well. Thanks for helping me out with that. I was pretty sure that the code I was using was older than sin. Thanks again


no problem. post again if ya ever need anything.