# Mouse follow \_x,\_y limits

**URL:** <https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043>\
**Category:** Uncategorized\
**Created:** [December 17, 2003, 2:30am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043 "2003-12-17T02:30:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hognav2t](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@hognav2t](https://forum.kirupa.com/u/hognav2t)\
**Post date:** [December 17, 2003, 2:30am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/1 "2003-12-17T02:30:18Z")

</div>

im totally new here. Hi !~~

heres my prob:

u know how, with startDrag u can specify left, top, rgt, bottom

values to restrict the mouse movement?

well, i wanna do the same to a mouse follower,…

any ideas?

im usin this code:

\_root.follower.\_x+=(\_root.\_xmouse-\_x)\*.3

thnx tons,

hog.

---

<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:** [December 17, 2003, 2:35am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/2 "2003-12-17T02:35:21Z")

</div>

just set the limits for the mouse:

if((\_xmouse \<= 990) && (\_xmouse\>=0) {  
\_root.mousebutton.\_x = \_xmouse;  
}

and same thing for y. good luck 🙂

---

<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:** [December 17, 2003, 2:40am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/3 "2003-12-17T02:40:48Z")

</div>

thnx MTsoul,

still wont work,

do i have the code right?

onClipEvent(enterFrame){  
\_root.follower.\_x+=(\_root.\_xmouse-\_x)\*.2  
if((\_xmouse \<= 300) && (\_xmouse\>=100)) {  
\_root.mousebutton.\_x = \_xmouse;  
}  
}

---

<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:** [December 17, 2003, 2:43am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/4 "2003-12-17T02:43:25Z")

</div>

oops i meant:

onClipEvent(enterFrame){  
\_root.sl2.\_x+=(\_root.\_xmouse-\_x)\*.2  
if((\_xmouse \<= 300) && (\_xmouse\>=100)) {  
\_root.follower.\_x = \_xmouse;  
}  
}

it kinda works now but it keeps runnin between the loc. of the  
current mouse and some loc. in the mc

thnx

---

<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:** [December 17, 2003, 2:44am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/5 "2003-12-17T02:44:36Z")

</div>

not quite sure what you mean by loc. can you show me your swf?

---

<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:** [December 17, 2003, 2:52am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/6 "2003-12-17T02:52:26Z")

</div>

sorry 4 some reason, i couldnt log in

---

<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:** [December 17, 2003, 2:54am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/7 "2003-12-17T02:54:06Z")

</div>

here it is

---

<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:** [December 17, 2003, 2:57am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/8 "2003-12-17T02:57:22Z")

</div>

thnx in advance 4 ur help

---

<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:** [December 17, 2003, 2:57am UTC](https://forum.kirupa.com/t/mouse-follow--x--y-limits/97043/9 "2003-12-17T02:57:24Z")

</div>

um…  
the fact that you are using that slowing down thing makes it hard to flash to carry the object to the border you want (in your case, 300). anyway, it probably will be like that.  
now you just have to make the y axis, with the same logic. just change all the x’s to y’s and change the border for it.

good job :thumb:

_edit_ that’s what i do 🙂
