日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

Flash實(shí)例教程:方塊動(dòng)畫特效制作_Flash教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:Flash cs3直線工具教程
本例為Flash CS3仿真藝術(shù)設(shè)計(jì)系列教程,本文我們將學(xué)習(xí)Flash cs3中直線工具的應(yīng)用,在flash中總是有幾個(gè)不同的方法取得相同的效果。在我們排列中使用所有的不同工具,我總是使用不同的方法使用它們?nèi)〉貌灰粯拥男Ч?dòng)畫渲染一般被歸類于“卡通渲染”。這種

效果如下:

1.新建一個(gè)flash Actionscript 3 大小為500×300px,背景黑色。

2.在場(chǎng)景里,使用矩形工具(G),設(shè)置邊框?qū)?px;畫一個(gè)正方形大小個(gè)40×40px;

3dbox2

3.將這個(gè)正方形上點(diǎn)右鍵,轉(zhuǎn)換元件(為電影剪輯);注冊(cè)設(shè)置為中心;

3dbox3

4.選擇元件,右鍵>鏈接;設(shè)置類為MyBox;

3dbox4

5.回到場(chǎng)景中刪除正方形;新建一個(gè)Actionscript文件并輸入下面代碼:

1

2

3

4

5

6

7

8

9

10

11

package {

	import flash.display.MovieClip;

	public class MyBox extends MovieClip {

		//這是方塊的3d坐標(biāo)

		public var xpos3D:Number = 0;

		public var ypos3D:Number = 0;

		public var zpos3D:Number = 0;

		public function MyBox() {

		}

	}

}

另存為MyBox.as,注意存在flash文件的同一路徑內(nèi),
6.返回主場(chǎng)景,在第一幀中插入下列代碼:

//立體場(chǎng)景縱深

const MAXIMUM_Z:Number = 500;

//方塊數(shù)量

const NUMBER_OF_BOXES:Number = 15;

//創(chuàng)建一個(gè)包含方塊的數(shù)組;

var boxes:Array = new Array();

//視圖焦距設(shè)置

var focalLength:Number = 300;

//Vanishingpoint是方塊消失點(diǎn);

var vanishingPointX:Number = stage.stageWidth / 2;

var vanishingPointY:Number = 20;

//3D方塊底邊位置

var floor:Number = 80;

//第一個(gè)方塊深度

var startingDepth:Number = MAXIMUM_Z;

//盒子之間的z距離值

var zDistance:Number = 50;

//這個(gè)循環(huán)為由遠(yuǎn)到近的方塊定位

for (var i=0; i < NUMBER_OF_BOXES; i  ) {

	var box:MyBox = new MyBox();

	box.xpos3D = 0;

	box.ypos3D = floor;

	box.zpos3D = startingDepth;

	//更新方塊的深度;

	startingDepth -= zDistance;

	//使用角度公式計(jì)算縮放比例;

	var scaleRatio = focalLength/(focalLength   box.zpos3D);

	//縮放坐標(biāo)比例;

	box.scaleX=box.scaleY=scaleRatio;

	//將方塊定位到場(chǎng)景中(由3d到2d轉(zhuǎn)換)

	box.x=vanishingPointX box.xpos3D*scaleRatio;

	box.y=vanishingPointY box.ypos3D*scaleRatio;

	//將方塊放入數(shù)組

	boxes.push(box);

	//將方塊加入場(chǎng)景

	addChild(box);

}

在菜單中選擇調(diào)試>測(cè)試場(chǎng)景效果如下:

3dbox7

7.在以上代碼后插入如下代碼,用于產(chǎn)生動(dòng)畫;

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

//用ENTER_FRAME事件加入動(dòng)畫函數(shù)

addEventListener(Event.ENTER_FRAME, enterFrameHandler);

 

//每一幀都調(diào)用這個(gè)函數(shù)

function enterFrameHandler(e:Event):void {

 

	for (var i=0; i < NUMBER_OF_BOXES; i  ) {

 

		//將box變?yōu)榫植孔兞?/SPAN>

		var box:MyBox = (MyBox)(boxes[i]);

		//減少深度

		box.zpos3D-=5;

		if (box.zpos3D<=- focalLength) {

			//最后方塊始終在數(shù)組第一位

			box.zpos3D=boxes[0].zpos3D zDistance;

		}

		var scaleRatio = focalLength/(focalLength   box.zpos3D);

		box.scaleX=box.scaleY=scaleRatio;

		//設(shè)置透明度變量

		box.alpha=scaleRatio-0.5;

		box.x=vanishingPointX box.xpos3D*scaleRatio;

		box.y=vanishingPointY box.ypos3D*scaleRatio;

	}

	//根據(jù)深度排列數(shù)組

	sortZ();

}

 

//這個(gè)函數(shù)使方塊正確排列

function sortZ():void {

	boxes.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);

	for (var i:uint = 0; i < NUMBER_OF_BOXES; i  ) {

		setChildIndex(boxes[i], i);

	}

}

分享:Flash CS4如何控制動(dòng)畫聲音的停止和播放
今天有閃友問到如何控制AS3中的聲音問題,用下面的小實(shí)例說明: /* As3Sound.as */ package { import flash.display.Sprite; import flash.events.*; import flash.media.Sound; import flash.media.SoundChannel; import flash.net.URLRequest; import flash

來源:網(wǎng)頁教學(xué)網(wǎng)//所屬分類:Flash教程/更新時(shí)間:2009-03-18
相關(guān)Flash教程