# HITTEST + ROLLOVER + \_xMOUSE?

**URL:** <https://forum.kirupa.com/t/hittest-rollover--xmouse/26799>\
**Category:** Uncategorized\
**Created:** [July 26, 2003, 11:15am UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799 "2003-07-26T11:15:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vulcan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_vulcan/32/145_2.png) [@The\_Vulcan](https://forum.kirupa.com/u/The_Vulcan)\
**Post date:** [July 26, 2003, 11:15am UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/1 "2003-07-26T11:15:12Z")

</div>

Please help.

I have a sliding menu that works fine. However I only want it to scroll when the mouse is over it. But everything I have tried causes errors.

The menu is in 2 parts, a mask “box” and the slider “slider”.  
The sider knows where the edges are from the box as below.  
[AS]  
top\_y = \_root.box.\_y;  
bottom\_y = top\_y-(this.\_height-\_root.box.\_height);  
[/AS]

So how can I set it up so that it only moves when the mouse is over the box ? The complete code below.  
[AS]  
onClipEvent (load) {  
ycenter = 175;  
speed = .1;  
top\_y = \_root.box.\_y;  
bottom\_y = top\_y-(this.\_height-\_root.box.\_height);  
}  
onClipEvent (enterFrame) {  
var distance = \_root.\_ymouse-ycenter;  
\_y -= (distance\*speed);  
if (this.\_y\>=top\_y) {  
this.\_y = top\_y;  
} else if (this.\_y\<=bottom\_y) {  
this.\_y = bottom\_y;  
}  
}  
[/AS]

Any help or pointers as I am at a dead end, thanks.

---

<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 26, 2003, 11:42am UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/2 "2003-07-26T11:42:21Z")

</div>

and you tried hittest or are you asking if thats an option? I think I would take that route. I assume the box bounding box is where you want to it to be active? just hitTest for that with \_root.\_xmouse and \_root.\_ymouse.

---

<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 26, 2003, 11:53am UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/3 "2003-07-26T11:53:34Z")

</div>

Thanks

I tried to use hittest but I’m not sure how to implement it ie: exactly where to put it and how to script it.

[AS]if (hitTest( \_root.\_xmouse, \_root.\_ymouse, false));[/AS]

---

<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 26, 2003, 12:07pm UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/4 "2003-07-26T12:07:37Z")

</div>

itd probably be something like this:  
[AS]  
onClipEvent (load) {  
ycenter = 175;  
speed = .1;  
top\_y = \_root.box.\_y;  
bottom\_y = top\_y-(this.\_height-\_root.box.\_height);  
}  
onClipEvent (enterFrame) {  
if (\_root.box.hitTest( \_root.\_xmouse, \_root.\_ymouse, false)){  
var distance = \_root.\_ymouse-ycenter;  
\_y -= (distance\*speed);  
if (this.\_y\>=top\_y) {  
this.\_y = top\_y;  
} else if (this.\_y\<=bottom\_y) {  
this.\_y = bottom\_y;  
}  
}  
}  
[/AS]

Then the enterFrame actions will only be called if the mouse is in the box.

---

<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 26, 2003, 12:15pm UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/5 "2003-07-26T12:15:21Z")

</div>

worked like a charm. Much appreciated.

---

<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 26, 2003, 12:26pm UTC](https://forum.kirupa.com/t/hittest-rollover--xmouse/26799/6 "2003-07-26T12:26:53Z")

</div>

great! 🙂
