# Detecting mouse bumps

**URL:** <https://forum.kirupa.com/t/detecting-mouse-bumps/214191>\
**Category:** Uncategorized\
**Created:** [January 26, 2007, 5:12am UTC](https://forum.kirupa.com/t/detecting-mouse-bumps/214191 "2007-01-26T05:12:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![santiv](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@santiv](https://forum.kirupa.com/u/santiv)\
**Post date:** [January 26, 2007, 5:12am UTC](https://forum.kirupa.com/t/detecting-mouse-bumps/214191/1 "2007-01-26T05:12:15Z")

</div>

I’m trying to detect a mouse motion thats intentional instead of an accidental bump. So, I have a function that detects if the mouse moves 10 pixels and displays a simple circle, and on click of the circle I want it to disappear, yet the circle still appears.

Why is it on click of circle, I still get values for x and y and sometimes it resets to 0 and 0?

Any ideas would be appreciated.

circle.\_visible = false;  
var active = true;  
var xChange:Number = 0;  
var yChange:Number = 0;  
//  
function mouseSpeed() {  
//circle.\_visible = false;  
xChange = 0;  
yChange = 0;  
xChange = Math.abs((\_root.\_xmouse-xMouse));  
yChange = Math.abs((\_root.\_ymouse-yMouse));  
xMouse = \_root.\_xmouse;  
yMouse = \_root.\_ymouse;  
trace(xChange+" "+yChange);  
if (xChange\>10) {  
if (active) {  
clearInterval(intervalId);  
circle.\_visible = true;  
trace(“clear Interval”);  
active = false;  
xChange = 0;  
yChange = 0;  
}  
}  
if (yChange\>10) {  
if (active) {  
clearInterval(intervalId);  
circle.\_visible = true;  
trace(“clear Interval”);  
active = false;  
xChange = 0;  
yChange = 0;  
}  
}  
}  
circle.onRelease = function() {  
circle.\_visible = false;  
active = true;  
beginInterval();  
};  
function beginInterval():Void {  
xChange = 0;  
yChange = 0;  
trace(“begin interval”);  
intervalId = setInterval(this, “mouseSpeed”, 100);  
}  
beginInterval();
