# Confining y pos. of mouse position

**URL:** <https://forum.kirupa.com/t/confining-y-pos-of-mouse-position/14402>\
**Category:** Uncategorized\
**Created:** [February 25, 2003, 9:28pm UTC](https://forum.kirupa.com/t/confining-y-pos-of-mouse-position/14402 "2003-02-25T21:28:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![invisible7](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@invisible7](https://forum.kirupa.com/u/invisible7)\
**Post date:** [February 25, 2003, 9:28pm UTC](https://forum.kirupa.com/t/confining-y-pos-of-mouse-position/14402/1 "2003-02-25T21:28:14Z")

</div>

I have an mc that changes color based on the mouse position in the fla. What I would like to do is define the y region for the mouse position so that the mc changes only when the mouse is in a specific y range (i only want the mc to play when the mouse moves hor. across a menu bar).

this is what i’m using.

onClipEvent(load){  
gotoAndStop(1);  
}

onClipEvent(enterFrame){  
goto = Math.round(\_root.\_xmouse/10);

gotoAndStop(goto);  
}

thanks for any 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:** [February 25, 2003, 9:58pm UTC](https://forum.kirupa.com/t/confining-y-pos-of-mouse-position/14402/2 "2003-02-25T21:58:17Z")

</div>

I don’t know if i got what you want right

but i think an if statement will solve your problem

just state in the if condition what boundries you want for example:

if (\_root.\_xmouse \>= 10 || \_root.\_xmouse \<= 100) {  
// any movieClip action you want  
}

the action you place between the braces will only work when the \_xmouse coordinate is inside the regions stated above

:tie:

---

<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:** [February 25, 2003, 11:12pm UTC](https://forum.kirupa.com/t/confining-y-pos-of-mouse-position/14402/3 "2003-02-25T23:12:45Z")

</div>

Thanks.

But I don’t understand how to incorperate the script into my existing script.

Also, the values for x and y (your example 10 & 100) do they represent pixile #'s, ie if my menu is 600 px long and 20 px high and upper corner position is 0/70 would my code look like this??

if (\_root.\_xmouse \>= 0 || \_root.\_xmouse \<= 600) {  
// any movieClip action you want  
}

if (\_root.\_ymouse \>= 70 || \_root.\_ymouse \<= 90) {  
// any movieClip action you want  
}

thanks
