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();