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

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

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

文章來源于 中國教程網(wǎng)論壇,感謝作者 cao4811 給我們帶來經(jīng)精彩的文章!
設(shè)計教程/設(shè)計教程/Flash教程2010-04-29
在這個3D旋轉(zhuǎn)菜單教程中,將學(xué)習(xí)如何用AS3代碼創(chuàng)建一個垂直的3D立體菜單效果,木馬將會根據(jù)鼠標(biāo)決定旋轉(zhuǎn)速度。

演示:

[swf]http://www.09yu.com/uploads/media/091014/1-1004291H324.swf[/swf]

1、新建Flash文件,設(shè)置寬、高屬性為 550 × 400 。

2、用圓角矩形工具,畫一個 158 × 35的長方形。筆觸為8白色,填充色#0 F7E 88。圖1:

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

3、將長方形轉(zhuǎn)換成名為 " Menu Item " 的影片剪輯。設(shè)定注冊點為中心。圖2:

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

4、雙擊舞臺上的影片剪輯,進(jìn)入編輯狀態(tài)。創(chuàng)建動態(tài)文本,在它里面輸入需要的本文。圖3

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

5、在屬性面板中輸入實例名字 " menuItemText" 。

6、按下字符嵌入按鈕,插入下列字型。圖4:

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

7、切換回主場景1,刪除舞臺上的影片剪輯,實例將由代碼生成。

8、打開庫元件面板,右鍵單擊影片剪輯,(CS3選鏈接、CS4選屬性)給元件添加一個綁定類。類名 " MenuItem" 。圖5:

Flash AS繪制旋轉(zhuǎn)的3D效果菜單動畫

9、選中第1幀,打開動作面板輸入代碼:

//The total number of menu items
const NUMBER_OF_ITEMS:uint = 20;
//This array will contain all the menu items
var menuItems:Array = new Array();
//Set the focal length
var focalLength:Number = 350;
//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;
//We calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;
//Radius of the circle
var radius:Number = 128;
//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
//This loop creates and positions the carousel items
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * i;
//Set a "currentAngle" attribute for the menu item
menuItem.currentAngle = startingAngle;
//Position the menu item
menuItem.xpos3D =  -  radius * Math.cos(menuItem.currentAngle) * 0.5;
menuItem.ypos3D = radius * Math.sin(startingAngle);
menuItem.zpos3D = radius * Math.cos(startingAngle);
//Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the menu item according to the scale ratio
menuItem.scaleX = menuItem.scaleY = scaleRatio;
//Position the menu item to the stage (from 3D to 2D coordinates)
menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
//Assign an initial alpha
menuItem.alpha = 0.3;
//Add a text to the menu item
menuItem.menuItemText.text = "Menu item " + i;
//We don’t want the text field to catch mouse events
menuItem.mouseChildren = false;
//Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
//Add the menu item to the menu items array
menuItems.push(menuItem);
//Add the menu item to the stage
addChild(menuItem);
}
//Add an ENTER_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveCarousel);
//This function is called in each frame
function moveCarousel(e:Event):void {
//Calculate the angle speed according to mouseY position
angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
//Loop through the menu items
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
//Store the menu item to a local variable
var menuItem:MenuItem = (MenuItem)(menuItems[i]);
//Update the current angle of the item
menuItem.currentAngle += angleSpeed;
//Calculate a scale ratio
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the item according to the scale ratio
menuItem.scaleX=menuItem.scaleY=scaleRatio;
//Set new 3D coordinates
menuItem.xpos3D=- radius*Math.cos(menuItem.currentAngle)*0.5;
menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
//Update the item’s coordinates.
menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;
menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;
}
//Call the function that sorts the items so they overlap each other correctly
sortZ();
}
//This function sorts the items so they overlap each other correctly
function sortZ():void {
//Sort the array so that the item which has the highest
//z position (= furthest away) is first in the array
menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
//Set new child indexes for the images
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
setChildIndex(menuItems[i], i);
}
}
//This function is called when a mouse is over an item
function mouseOverItem(e:Event):void {
//Change the alpha to 1
e.target.alpha=1;
}
//This function is called when a mouse is out of an item
function mouseOutItem(e:Event):void {
//Change the alpha to 1
e.target.alpha=0.3;
}
//This function is called when an item is clicked
function itemClicked(e:Event):void {
trace("Item clicked! Add your own logic here.");
}

 

10、完成,測試你的影片。

源文件請到論壇:http://www.missyuan.com/viewthread.php?tid=454675

版權(quán)所有PS設(shè)計教程網(wǎng)公安備案:蘇公網(wǎng)安備 32058302001023號工信部備案:滬ICP備09005587號
aaa
主站蜘蛛池模板: 久草视频在线资源 | 久久久久久久午夜 | 日韩一级片 | sese在线视频 | 男男羞羞视频网站国产 | 国产欧美日韩视频在线观看 | 亚洲天堂成人在线观看 | 98国内自拍在线视频 | 一级全毛片 | 欧美一级片免费在线观看 | 色淫网站免费视频 | 久久91精品国产91久久yfo | 成人免费观看49www在线观看 | 香蕉秀| 欧美日本国产精品 | 国产精品视频一区二区噜噜 | 国产二区三区视频 | 国产小视频在线观看 | 欧产日产国产精品乱噜噜 | 成人性生活视频在线播放 | 国产无限资源在线观看 | 精品久久久久久亚洲精品 | 色99999| 91av亚洲| 精品一区二区视频在线观看 | 国产精品视频中文字幕 | 在线亚洲免费 | 欧美在线中文字幕 | 黄色视屏免费观看 | 中文字幕在线免费观看电影 | 成人福利视频在线观看 | 操操操日日日干干干 | 色女人在线 | 91av资源在线 | 国内xxxx乱子另类 | 欧美自拍 | 男男羞羞视频网站国产 | 欧美日韩国产一区二区三区在线观看 | 一级黄色在线免费观看 | omofun 动漫在线观看 | 一区二区三区小视频 |