Flash AS3教程:创建好看的遮罩动画效果

1、新建Flash文件,导入所需的图片到舞台,设置舞台属性的宽、高同图片相同大小。

2、将图片设置为左对齐、上对齐。右键单击图片转换成影片剪辑,命名为“Background”,设置注册点为居中。图1:
sshot-1.png 
3、将图层1改名为背景,在属性面板中输入实例名称:“backgroundImage” 锁定。图2:
sshot-2.png 
4、新建一个图层,用椭圆工具画一个禁止笔触的50*50的圆,填充色任意。

5、把圆转换成影片剪辑,设置如下。图3:
sshot-3.png 
6、删除舞台上的圆,图层改名为as。至此fla的美工已全部完成。

7、新建ActionScript文件,编写一个外部的MyMask.as文件。在编译器中输入代码: 
package { 

        import flash.display.MovieClip; 

        public class MyMask extends MovieClip { 

                //Mask’s x and y speed 

                public var speedX:Number; 

                public var speedY:Number; 

                //Set the given scale for this mask, when we create a new 

                //mask object 

                public function MyMask(scale:Number) { 

                        this.scaleX = scale;