# Need some help with AS for MouseFollower

**URL:** <https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647>\
**Category:** Uncategorized\
**Created:** [August 30, 2004, 6:52am UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647 "2004-08-30T06:52:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azazel](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Azazel](https://forum.kirupa.com/u/Azazel)\
**Post date:** [August 30, 2004, 6:52am UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647/1 "2004-08-30T06:52:38Z")

</div>

Hi everybody…

I’ve used the following AS to make a little thingy follow the mouse on the x axis, but i’d like to specify a range, where it starts to follow, and where i stops to follow… how would i go about doing that?

```auto
onClipEvent (load) {
	_x = 5;
	speed = 5;
}
onClipEvent (enterFrame) {
	endX = _root._xmouse;
	_x += (endX-_x)/speed;
}

```

any takers :sigh: ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2004, 2:20pm UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647/2 "2004-08-30T14:20:30Z")

</div>

K, i putt a mask on it. And that helpt (a little). But i want the mouse follower to STOP within the " boundry box"… anyone? :book:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2004, 4:15pm UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647/3 "2004-08-30T16:15:34Z")

</div>

K, i putt a mask on it. And that helpt (a little). But i want the mouse follower to STOP within the " boundry box"… anyone? :book:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 31, 2004, 1:30pm UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647/4 "2004-08-31T13:30:13Z")

</div>

ok, here is a link to something like what i’m after… [insede on the bottom, see what i meen?](http://www.templates247.com/t38/index.html)  
:mu:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 31, 2004, 11:06pm UTC](https://forum.kirupa.com/t/need-some-help-with-as-for-mousefollower/62647/5 "2004-08-31T23:06:33Z")

</div>

if you want to speciffy a range you can simply do something like this

```auto
onClipEvent (load) {
	_x = 5;
	speed = 5;
}
onClipEvent (enterFrame) {
	if (_root._xmouse < 500 && _root._xmouse > 100){
\\ will set the endX on _root._xmouse only if _x is between 100 and 500
endX = _root._xmouse;}
else {
endX = 50; \\ else it returns in a 50 position
}
	_x += (endX-_x)/speed;
} 

```

But on the link you posted it’s not a real mouse follow. I mean that rounded rectangle thingy does not actually follow the mouse, but rather focuses on the coordinates of a button.  
So… you should keep the onEnterframe only and set the endX **on (rollOver)** of your buttons and then on rollout you should set endX to a neutral position.

```auto
onClipEvent (load) {
	_x = 5;
	speed = 5;
}
onClipEvent (enterFrame) {
	_x += (endX-_x)/speed;
} 

```

and for buttons

```auto

on (rollOver) {
endX = this._x; \\hopeing that this._x is in the center :)
}
on (rollOut) {
endX = 50; \\ whatever the x coordinates of the neutral position would be
}

```

Let me see what you manage to do out of this effect :).
