# Mouse Bounds

**URL:** <https://forum.kirupa.com/t/mouse-bounds/24549>\
**Category:** flash\
**Created:** [July 2, 2003, 1:10am UTC](https://forum.kirupa.com/t/mouse-bounds/24549 "2003-07-02T01:10:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hagel](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hagel/32/262_2.png) [@hagel](https://forum.kirupa.com/u/hagel)\
**Post date:** [July 2, 2003, 1:10am UTC](https://forum.kirupa.com/t/mouse-bounds/24549/1 "2003-07-02T01:10:22Z")

</div>

I currently have a Nav that I am working on that will follow the mouse’s \_y position. I am wanting to have bounds set that keep the nav in between certain top \_y and bottom \_y, but am lost on how to do it.

I have tried applying the same techniques that I would to create bounds for a Dragging menu (define top and bottom bounds) but it didn’t work with the mouse position.

Here is the code so far that makes the menu follow the mouse:

speed = 25;  
menu\_mc.onEnterFrame = function () {  
target\_y = \_root.\_ymouse - this.\_y;  
this.\_y = this.\_y + (target\_y/speed);  
}

Any help would be appreciated.

## Thanks,

Michael

---

<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:** [July 2, 2003, 1:24am UTC](https://forum.kirupa.com/t/mouse-bounds/24549/2 "2003-07-02T01:24:05Z")

</div>

speed = 25;  
menu\_mc.onEnterFrame = function () {  
tempy = \_root.\_ymouse;  
if (tempy \> topvalue) tempy = topvalue;  
if (tempy \< bottomvalue) tempy = bottomvalue;  
this.\_y = (tempy - this.\_y)/speed;

}

---

<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:** [July 2, 2003, 1:31am UTC](https://forum.kirupa.com/t/mouse-bounds/24549/3 "2003-07-02T01:31:15Z")

</div>

Tried that and now it just stays at the top.

I tried defining a variable

topvalue = 33;  
bottomvalue = 663;

But no luck.

Did I do something wrong.

Thanks for the response!

–  
Michael

---

<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:** [July 2, 2003, 2:41am UTC](https://forum.kirupa.com/t/mouse-bounds/24549/4 "2003-07-02T02:41:39Z")

</div>

This should certainly get you started.
