国产乱视频网站_久久亚洲一区二区三区四区_免费高清一级毛片_国产精品电影_国产精品乱码一区二区三区_美女天堂网

PS設(shè)計教程網(wǎng)歡迎你!

Flash AS3教程:創(chuàng)建好看的遮罩動畫效果

文章來源于 中國教程網(wǎng)論壇,感謝作者 cao4811 給我們帶來經(jīng)精彩的文章!
設(shè)計教程/設(shè)計教程/Flash教程2010-01-28
本教程是一個創(chuàng)建遮罩效果的教程,將學(xué)習如何在一個圖像上創(chuàng)建多個大小不同的運動遮罩。下面一起來學(xué)習。

演示:


1、新建Flash文件,導(dǎo)入所需的圖片到舞臺,設(shè)置舞臺屬性的寬、高同圖片相同大小。

2、將圖片設(shè)置為左對齊、上對齊。右鍵單擊圖片轉(zhuǎn)換成影片剪輯,命名為“Background”,設(shè)置注冊點為居中。圖1:
Flash AS3教程:創(chuàng)建好看的遮罩動畫效果
3、將圖層1改名為背景,在屬性面板中輸入實例名稱:“backgroundImage” 鎖定。圖2:
Flash AS3教程:創(chuàng)建好看的遮罩動畫效果
4、新建一個圖層,用橢圓工具畫一個禁止筆觸的50*50的圓,填充色任意。

5、把圓轉(zhuǎn)換成影片剪輯,設(shè)置如下。圖3:
Flash AS3教程:創(chuàng)建好看的遮罩動畫效果
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;

                        this.scaleY = scale;

                }

        }

}

這是一個名為MyMask.as的遮罩類,保存在fla文件的同一目錄下。

8、切換到fla,在as層輸入代碼:



//We use an array to hold all our masks.

//(Except the mask that follows our cursor)

var masks:Array = new Array();



//We add all of the masks to a container

var maskContainer:Sprite = new Sprite();



//Set the maskContainer to be the image’s mask

backgroundImage.mask = maskContainer;



//Add the container on the stage

addChild(maskContainer);



//Create the mask which follows cursor movement (master mask)

var masterMask:MyMask = new MyMask(1);



//Set the master masks’s coordinates to match cursor’s coordinates

masterMask.x = mouseX;

masterMask.y = mouseY;



//Add the master mask to a container

maskContainer.addChild(masterMask);



//Cache the image and container as bitmap, so we

//can animate the alpha of the masks

maskContainer.cacheAsBitmap=true;

backgroundImage.cacheAsBitmap=true;



//Create a timer that is called every 0.2 seconds

var timer:Timer = new Timer(200,0);

timer.addEventListener(TimerEvent.TIMER, timerEvent);

timer.start();



//This function is called every 0.2 seconds.

//We create a new mask in this function.

function timerEvent(e:TimerEvent):void {



        //Calculate a random scale for the new mask (0 to 1.5)

        var scale:Number = Math.random() * 1.5 + 0.5;



        //Create a new mask with random scale

        var newMask:MyMask = new MyMask(scale);



        //Set the position for the new mask

        newMask.x = mouseX;

        newMask.y = mouseY;



        //Assign a random x and y speed for the mask

        newMask.speedX = Math.random() * 20 - 10;

        newMask.speedY = Math.random() * 20 - 10;



        //Add the mask to the container

        maskContainer.addChild(newMask);



        //Add the mask to the array

        masks.push(newMask);

}



//We need ENTER_FRAME to animate the masks

addEventListener(Event.ENTER_FRAME, enterFrameHandler);



//This function is called in each frame

function enterFrameHandler(e:Event):void {



        //Loop through the mask array

        for (var i:uint = 0; i < masks.length; i++) {



                //Save a mask to a local variable

                var myMask:MyMask = (MyMask)(masks[i]);



                //Update the x and y position

                myMask.x += myMask.speedX;

                myMask.y += myMask.speedY;



                //Increase the scale

                myMask.scaleX += 0.1;

                myMask.scaleY += 0.1;



                //Reduce the alpha

                myMask.alpha -= 0.01;



                //If the alpha is below 0, remove the mask

                //from the container and from the array

                if (myMask.alpha < 0) {

                        masks.splice(i,1);

                        maskContainer.removeChild(myMask);

                }

        }



        //Update the master mask position

        masterMask.x = mouseX;

        masterMask.y = mouseY;

}

9、好了,工作全部完成,測試你的影片。
 

版權(quán)所有PS設(shè)計教程網(wǎng)公安備案:蘇公網(wǎng)安備 32058302001023號工信部備案:滬ICP備09005587號
aaa
主站蜘蛛池模板: 欧美日韩国产一区二区三区 | 欧美一区二区三区黄色 | 羞羞网站在线观看入口免费 | 国产精品11| 国产视频一区二区在线观看 | 国产欧美一区二区精品性色 | 在线免费av观看 | 2018啪一啪| 亚洲免费黄色 | 国产色在线观看 | 99精品视频一区二区三区 | 亚洲一区视频 | 99久久综合狠狠综合久久 | 欧美成年黄网站色视频 | 91在线观看视频 | 久久六月 | 国产超碰人人模人人爽人人添 | 毛片入口 | 干干干操操操 | 国产黄色免费网站 | 中文字幕在线一区二区三区 | 欧美系列第一页 | 中文在线一区二区 | 国产激情精品一区二区三区 | 一级黄色录象片 | 国产九九精品 | 色呦呦在线观看视频 | 久久久美女 | 免费毛片视频 | 亚洲视频中文字幕 | 午夜电影网站 | 久久艹国产视频 | 久久福利| www312aⅴ欧美在线看 | 亚洲成人福利在线观看 | www.久久伊人| 天天干天天曰天天操 | 亚洲协和影视 | 亚洲精品视频国产 | 国产一区二区自拍视频 | 欧美极品视频 |