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

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
主站蜘蛛池模板: 91麻豆精品一区二区三区 | 日韩一区二区福利 | 黄色综合网站 | 一区二区不卡视频在线观看 | 国产91视频一区二区 | 国产成人亚洲综合 | 激情91 | 一区二区欧美在线 | 中文字幕在线观看亚洲 | 日韩精品一二区 | 在线观看免费视频日韩 | 成人av网站免费观看 | 成人久久久精品国产乱码一区二区 | 成人黄色电影小说 | 中文字幕在线观看的电影 | 99精品久久久久久久免费看蜜月 | 国产精品自拍一区 | 国产精品一区二区在线观看免费 | 日韩一区二区精品视频 | 国产青青 | 国产一级黄色大片 | 亚洲精美视频 | 亚洲人人艹| 国产成人久久精品一区二区三区 | 性做久久久久久久免费看 | 久久久久久久一区二区三区 | 91激情在线| 午夜精品视频在线观看 | 日韩精品一区在线 | 国产黄在线观看 | 久久久精品高清 | 四虎在线播放 | 美日韩精品 | 在线观看免费污 | 国产精品视频入口 | 免费一区 | 特级毛片| 亚洲一区 日韩精品 中文字幕 | 国产一区91 | 97久久超碰国产精品电影 | 黄a在线观看 |