[AS1] Mouse Speed Detection Problem!

I’ve been facing this problem for years and I finally decided to try and find the answer to it. I use something like this code to detect the speed of the movement of a dragged object

if (!go) {
		this["position_"+i] = this._y;
		i++;
		if (i == 3) {
			i = 1;
		}
		delta_y = this.position_2-this.position_1;
	}

This way I can find in what direction the mouse vertically has moved and at what speed. The problem is that every once in a while the speed will be in the opposite direction. What do people use to detect the direction of the movement of the mouse?
:confused:

Shouts out = HELP!

what do you mean in the opposite direction? if you’re just wnating to find the speed the mouse is moving you couls use some basic pythagoras. this will work no matter what way you move the mouse:

onClipEvent(load) {
	prevX = _root._xmouse;
	prevY = _root._ymouse;
}
onClipEvent(enterFrame) {
	x = _root._xmouse - prevX;
	y = _root._ymouse - prevY;
	speed = Math.sqrt((x*x) + (y*y));
	trace(speed);
	prevX = _root._xmouse;
	prevY = _root._ymouse;
}

hope this helps you.