• 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, onMouseUp_func);
     
    function onMouseDown_func(_evt:MouseEvent):void{
        stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
    }
     
    function onMouseUp_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;
    }
    

      

  • 相关阅读:
    Gym
    博客搬家
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA1589——xiangqi
    SDUSToj第十一次作业源代码格式问题
    【成长之路】【python】python基础3
  • 原文地址:https://www.cnblogs.com/dt1991/p/7542566.html
Copyright © 2020-2023  润新知