日本a在线观看_久久久三区_久久99精品久久久久久国产越南_在线观看中文字幕av_国产精品久久久久久久久久东京_a免费视频

PS設計教程網歡迎你!

Flash AS3教程:創建好看的遮罩動畫效果

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

演示:


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

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

5、把圓轉換成影片剪輯,設置如下。圖3:
Flash AS3教程:創建好看的遮罩動畫效果
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、好了,工作全部完成,測試你的影片。
 

版權所有PS設計教程網公安備案:蘇公網安備 32058302001023號工信部備案:滬ICP備09005587號
aaa
主站蜘蛛池模板: 特逼视频 | 色日本视频 | 日本不卡一区二区在线观看 | 精品无吗乱吗av国产爱色 | 最新中文在线视频 | 欧美日韩大片在线观看 | 亚洲一二区精品 | 国产精品久久久久久久久久久久午夜 | 4399一级成人毛片 | 精品一区二区三区免费毛片 | 国产黄色网 | 在线观看第一区 | 福利在线国产 | 草草视频在线 | 精品久久久久久 | 国产亚洲欧美日韩高清 | 91精品成人福利在线播放 | 在线91视频| 在线观看免费毛片视频 | 免费看欧美一级特黄a毛片 九色com | 91精品国产乱码久久久久 | 日韩黄色片免费看 | 亚洲精品日韩色噜噜久久五月 | 久色porn | 欧美一级做一a做片性视频 日韩黄色片免费看 | 国产精品一区二区三区在线播放 | 欧美一级做一级爱a做片性 91在线视频观看 | 国产精品久久久久久久久久久天堂 | 国产精品久久亚洲 | 免费a级观看 | 国产成人精品一区二区视频免费 | 牛牛a级毛片在线播放 | 天天干天天透 | 中文字幕爱爱视频 | 国产精品成人久久 | 黄色成人在线 | 久久最新网址 | 亚洲精品a级| 国产噜噜噜 | 亚洲网站一区 | 国产正在播放 |