论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash教程
Tag:flash cs,flash 8,鼠绘,as,手绘,工具,文字,loading,入门,初学,mc,影片剪辑,声音,mtv,游戏,引导,遮罩,菜单,补间,广告条,时钟,视频教程

一个放大效果的实现

文章类别:Flash | 发表日期:2008-9-21 19:52:26

  更新(加了鼠标滚动放大):

/UploadTeach/200809/20080904134805287.swf
代码如下:
/*---design by whb in 2008-9-1---
参数变量:mc:需要放大的图形*/
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
视频教程列表
文章教程搜索
 
Flash推荐教程
Flash热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058