# \[fmx2004\]Detecting mouse position

**URL:** https://forum.kirupa.com/t/fmx2004-detecting-mouse-position/211729
**Category:** flash
**Created:** [January 4, 2007, 5:10pm UTC](https://forum.kirupa.com/t/fmx2004-detecting-mouse-position/211729 "2007-01-04T17:10:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![peaceendeavor](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@peaceendeavor](https://forum.kirupa.com/u/peaceendeavor)
#### Post date: [January 4, 2007, 5:10pm UTC](https://forum.kirupa.com/t/fmx2004-detecting-mouse-position/211729/1 "2007-01-04T17:10:02Z")

</div>

I am new to Flash and Actionscripting. I found a script and am tailoring it to my needs. It is a script that finds the location of the users mouse and then scrolls a menu according to the position of the mouse:

mouseX = \_xmouse;  
mouseY = \_ymouse;  
menu\_butX = menu\_but.\_x;

if (mouseY \> 240 && mouseY \< 315) {

if (mouseX \> 247) {  
diff = (mouseX-247)/30;  
}  
if (mouseX \< 220) {  
diff = (220-mouseX)/30;  
}  
if (mouseX \<= 247 && menu\_butX \<= 253) {  
setProperty(“menu\_but”, \_x, menu\_butX+diff);  
}  
if (mouseX \>= 247 && menu\_butX \>= -6000) {  
setProperty(“menu\_but”, \_x, menu\_butX-diff);  
}  
if (menu\_but.\_x \>= 253) {  
menu\_but.\_x = 253;  
} else if (menu\_but.\_x \<= -6000) {  
menu\_but.\_x = -6000;  
}  
gotoAndPlay(2);  
};

Very simple I’m sure, but as I am making use of it, I notice clues that may indicate I am doing things improper… when I control\>test the movie, the playhead indicates it is repeatedly looping the frames from 1 to 3 (which is how many I have in the main time line) and when I upload and play the movie within a browser, the browser eventually hangs up as if memory is never released (correct terminology?). I have the above code in frame three of the main time line and the movie clip “menu\_but” is only one part of the main time line. I would think that the above code would only need to run when the mouse rolls over the movie clip - but this is where I have trouble… when I attempt to have the code be in the time line of the menu\_but movie clip and then play only when moused over, the result is an error message that rollover can only be applied to buttons.  
Any clues as to the direction I need to be going to solve this would be appreciated.
