PDA

View Full Version : Determining direction of Mouse Movement



Danneman
March 20th, 2004, 04:54 AM
Hi,

Is there a way to determine the direction in which the mouse-cursor is moving (up/down)?

Kinda like a constant listener, or something.

I only know about the onMouseMove-function, but it doesnt seem to come with parameters for direction.

Maby there is something that can be done with the:

_ymouse

..parameter. Something similar to:

_ymouse ++;

..to indicate the mouse-cursor is moving downwards.

Thanks

Seticus
March 20th, 2004, 05:28 AM
given to a frame:this.onMouseMove = function() {
if (_root._ymouse<prevpos) {
trace("going up");
} else if (_root._ymouse>prevpos) {
trace("going down");
}
prevpos = _root._ymouse;
};is probably the easiest way to tell you the direction of the mouse :)

scotty
March 20th, 2004, 05:39 AM
Seticus, that was my text:smirk:
*beaten*

scotty(-:

Seticus
March 20th, 2004, 05:48 AM
Next time, I'll wait a sec :whistle:

Danneman
March 20th, 2004, 03:02 PM
Originally posted by Seticus
given to a frame:this.onMouseMove = function() {
if (_root._ymouse<prevpos) {
trace("going up");
} else if (_root._ymouse>prevpos) {
trace("going down");
}
prevpos = _root._ymouse;
};is probably the easiest way to tell you the direction of the mouse :)

Simple and beautiful - just what code should be like.

Thanks a lot, Seticus :)

Seticus
March 20th, 2004, 03:45 PM
you're welcome