最新下载
热门教程
- 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
效果图.
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20