其他分享
首页 > 其他分享> > as3 判断鼠标移动方向

as3 判断鼠标移动方向

作者:互联网

import flash.events.MouseEvent;
var odx:Number=mouseX;
var ody:Number=mouseY;
stage.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown_func)
stage.addEventListener(MouseEvent.MOUSE_UP, onm ouseUp_func);
  
function onm ouseDown_func(_evt:MouseEvent):void{
    stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
  
function onm ouseUp_func(_evt:MouseEvent):void{
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
  
function onMove(e:MouseEvent):void{
    var newx:Number=mouseX;
    var newy:Number=mouseY;
    if(newx>odx)trace("鼠标在右移")else trace("鼠标在左移")
    if(newy>ody)trace("鼠标在下移")else trace("鼠标在上移")
     
    odx=newx;
    ody=newy;
}

  

标签:as3,鼠标,trace,MouseEvent,Number,var,移动,MOUSE
来源: https://www.cnblogs.com/fengziwu/p/15332502.html