as3.0 判断圆圈正转还是倒转

import flash.events.MouseEvent;
import flash.display.MovieClip;

var panArr:Array = [];

pan.addEventListener(MouseEvent.MOUSE_DOWN,panDown);
function panDown(e:MouseEvent) {
    stage.addEventListener(MouseEvent.MOUSE_UP,panUp);
    stage.addEventListener(MouseEvent.MOUSE_MOVE,panMove);
}
function panMove(e:MouseEvent) {
    pan.rotation=180/Math.PI*Math.atan2(mouseY-pan.y,mouseX-pan.x)+90;
    panArr.push(pan.rotation);
    var num:Number = panArr[panArr.length - 1] - panArr[panArr.length - 2];
    if (num>0) {
        trace("正转");
    } else {
        trace("倒转");
    }
    if (panArr.length > 3) {
        panArr.shift();
    }
}
function panUp(e:MouseEvent) {
    stage.removeEventListener(MouseEvent.MOUSE_MOVE,panMove);
    stage.removeEventListener(MouseEvent.MOUSE_UP,panUp);
}

posted on 2019-12-12 12:26  zqiang0803  阅读(192)  评论(0编辑  收藏  举报

导航