1. 程式人生 > >as3 判斷移動方向

as3 判斷移動方向

cti end ber listen class down light else ace

var oldX:Number;

stage.addEventListener(MouseEvent.MOUSE_DOWN,downF);
stage.addEventListener(MouseEvent.MOUSE_UP,upF);


function downF(e:Event)
{
	oldX = stage.mouseX;
}
function upF(e:Event)
{
	var endX = stage.mouseX;
	if (oldX - endX > precision)
	{
		trace("鼠標向左滑了");
		
	}
	else if (oldX - endX < -precision)
	{
		trace("鼠標向右滑了");
	}
}

  

as3 判斷移動方向