View Full Version : Detect mouse stopping?
mhunki
June 22nd, 2004, 12:37 PM
Thinking out loud really, is there a way to detect a mouse stopping?
I've created something that reacts to the mouse x & y position, just wondered if there was some way of detecting if it stops moving?
Mhunki
ScriptFlipper
June 22nd, 2004, 12:45 PM
something like this?
oldx = _root._xmouse;
oldy = _root._ymouse;
detectMouseMovement = function () {
// if the mouse position is the same as last time it was checked, it must have stopped
if (_root._xmouse == oldx && _root._ymouse == oldy) {
trace("It stopped");
}
// update variables that holds mouse positions
oldx = _root._xmouse;
oldy = _root._ymouse;
};
itv = setInterval(detectMouseMovement, 500);
mhunki
June 23rd, 2004, 04:00 AM
Looks good, I can see the sense now, I'll give it a try.
Thanks.
mhunki
June 23rd, 2004, 04:16 AM
Hey works!
forums come to the rescue once again!
Thanks
Prophet
June 23rd, 2004, 01:50 PM
couldnt you just use the onMouseMove method? (i dunno coz i dont know much bout objects an listeners an stuff.... yet ;) lol)
Prophet.
ScriptFlipper
June 23rd, 2004, 02:58 PM
Yeah you could, but not on the _root timeline. You need to cover the whole stage with an invisible area and apply the onMouseOver to that I think
Prophet
June 23rd, 2004, 03:02 PM
no i meant onMouseMove... i got the impression that it did exactly what he was askin for so i looked at flash help about it an gave up after a few mins hehe
Prophet.
ScriptFlipper
June 23rd, 2004, 06:06 PM
no i meant onMouseMove... i got the impression that it did exactly what he was askin for so i looked at flash help about it an gave up after a few mins hehe
Prophet.
oh yeah, sorry, I mean onMouseMove too :D
but it's still the same - it has to be called from a movieclip, which would have to cover the whole stage - I THINK :puzzle: ;)
Freddythunder
June 23rd, 2004, 08:00 PM
Actually, you can define functions onMouseMove to detect if the mouse is moving; but I like ScriptFlipper's way better - it's more creative :P
Like this:
createEmptyMovieClip("holder", 0);
holder.lineStyle(2, 0x00FF00, 100);
holder.beginFill(0xFF0000, 100);
holder.moveTo(0, 0);
holder.lineTo(20, 0);
holder.lineTo(20, 20);
holder.lineTo(0, 20);
holder.lineTo(0, 0);
holder.endFill();
onMouseMove = function () {
holder._x = _root._xmouse*2;
holder._y = _root._ymouse*2;
};
onEnterFrame = function () {
diffx = 0-holder._x;
diffy = 0-holder._y;
holder._x += diffx/2;
holder._y += diffy/2;
};
Prophet
June 23rd, 2004, 08:22 PM
well yeah i no the onMouseMove seems to suck... lol
an i musta forgotten to say "i like ur workaround" coz thas wat i was thinkin! :P
i just thought that the onMouseMove function sounds like it was born for this kinda stuff an was askin why he dint "just" use that... answer? coz it sucks! lol
cheers peeps... i feel a lil bit more enlightened ;)
Prophet.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.