参数变量:mc:需要放大的图形*/ as 3.0做放大镜效果代码
package maths{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.events.MouseEvent;
import flash.geom.Point;
public class ZoomImage extends Sprite {
private var sprBitmapData:BitmapData;
private var sprBitmap:Bitmap;
private var Rect:Rectangle;
private var Matr:Matrix;
private var mc:Sprite;
private var Mdown_x,Mdown_y,Mup_x,Mup_y:Number;
public function ZoomImage(_mc:Sprite) {
mc=_mc;
mc.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,Mdown_fc);
mc.addEventListener(flash.events.MouseEvent.MOUSE_MOVE,Mmove_fc);
mc.addEventListener(flash.events.MouseEvent.MOUSE_UP,Mup_fc);
}//end of ZoomImage
private function Mdown_fc(e:flash.events.MouseEvent) {
Mdown_x=e.localX;
Mdown_y=e.localY;
}//end of Mdown_fc
private function Mmove_fc(e:flash.events.MouseEvent) {
}//end of Mmove_fc
private function Mup_fc(e:flash.events.MouseEvent) {
if (e.localX > Mdown_x && e.localY > Mdown_y) {
var localPoint=new Point(Mdown_x,Mdown_y);
if (sprBitmap != null) {
removeChild(sprBitmap);
}
Mup_x=e.localX;
Mup_y=e.localY;
Matr=new Matrix(1,0,0,1,- Mdown_x,- Mdown_y);
sprBitmapData=new BitmapData(Mup_x - Mdown_x,Mup_y - Mdown_y);
sprBitmap=new Bitmap(sprBitmapData);
sprBitmapData.draw(mc,Matr);
addChild(sprBitmap);
this.scaleX=this.scaleY=2;
this.x=mc.localToGlobal(localP).x;
this.y=mc.localToGlobal(localP).y;
//
this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,MD_fc);
this.addEventListener(flash.events.MouseEvent.MOUSE_UP,MU_fc);
this.addEventListener(flash.events.MouseEvent.MOUSE_WHEEL,MW_fc);
}
}//end of Mup_fc
private function MW_fc(e:flash.events.MouseEvent) {
if (e.target.scaleX>1&&e.target.scaleX<5) {
e.target.scaleX+=0.03*e.delta;
e.target.scaleY+=0.03*e.delta;
}else{
e.target.scaleX=e.target.scaleY=1.1;
}
}//end of MW_fc
private function MD_fc(e:flash.events.MouseEvent) {
e.target.startDrag();
}//end of MD_fc
private function MU_fc(e:flash.events.MouseEvent) {
e.target.stopDrag();
}//end of MU_fc
}//end of class
}//end of package
效果图.
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内