最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
as 3.0做放大镜效果代码
时间:2022-07-02 17:04:04 编辑:袖梨 来源:一聚教程网
参数变量: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
效果图.
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21