Flash类的运用:可放大、缩小、旋转的鼠标操作类代码介绍

2019-10-08 12:29:53丽君

no();
currentOp.y=rBorder.y+rBorder.height-r.height/2;
}
return 0
}
//取消的所有动作
public function no():void {
isDrog=false;
clrPoint();
if (spPoint) {
spPoint.stopDrag();
}
currentOp.stopDrag();
}
//重新设置注册点
private function seCentXY():void {
var pTem:Point;
switch (pointType) {
case 1 :
pTem=currentOp.globalToLocal(new Point(arrPoint[4].x, arrPoint[4].y));
break;
case 2 :
pTem=currentOp.globalToLocal(new Point(arrPoint[5].x, arrPoint[5].y));
break;
case 3 :
pTem=currentOp.globalToLocal(new Point(arrPoint[6].x, arrPoint[6].y));
break;
case 4 :
pTem=currentOp.globalToLocal(new Point(arrPoint[7].x, arrPoint[7].y));
break;
case 5 :
pTem=currentOp.globalToLocal(new Point(arrPoint[0].x, arrPoint[0].y));
break;
case 6 :
pTem=currentOp.globalToLocal(new Point(arrPoint[1].x, arrPoint[1].y));
break;
case 7 :
pTem=currentOp.globalToLocal(new Point(arrPoint[2].x, arrPoint[2].y));
break;
case 8 :
pTem=currentOp.globalToLocal(new Point(arrPoint[3].x, arrPoint[3].y));
break;
}
opObject.RegPoint(currentOp, pTem);
}
private function fun_point_down(e:MouseEvent):void {
//
var spTem:Sprite=e.target as Sprite;
spPoint=spTem;
if (spRotationPoint == spPoint) {
var dx:Number=currentOp.parent.mouseX - pCent.x;
var dy:Number=currentOp.parent.mouseY - pCent.y;
nowRotation-=(Math.atan2(dy, dx) * 180 / Math.PI);
var pTem:Point=currentOp.globalToLocal(pCent);
opObject.RegPoint(currentOp, pTem);
spTem.alpha=0;
clrPointSize();
} else {
pointType=0;
for (var i:uint=0; i < arrPoint.length; i++) {
if (arrPoint[i] == spTem) {
pointType=i + 1;
break;
}
}
seCentXY();
}
isDrog=true;
spTem.startDrag(true);
}
private function fun_point_up(e:MouseEvent):void {
nowRotation=currentOp.rotation;
clrPoint();
}
private function isUpObj(sp:Sprite):Boolean {
var isRe:Boolean=false;
if (currentOp == sp) {
isRe=true;
} else {
for (var i:uint=0; i < arrPoint.length; i++) {
if (arrPoint[i] == sp) {
isRe=true;
break;
}
}
//
if (spRotationPoint == sp) {
isRe=true;
}
}
return isRe;
}
public function fun_Mouse_up(e:MouseEvent):void {
isDrog=false;
if (!isUpObj(e.target as Sprite)) {
clrPoint();
} else {
if (spPoint) {