




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、AS3.0 3D旋轉(zhuǎn)木馬效果實(shí)例在這個(gè) 3D旋轉(zhuǎn)菜單教程中,將學(xué)習(xí)如何用 AS3 代碼創(chuàng)建一個(gè)垂直的 3D立體菜單效果。木馬將會(huì)根據(jù)鼠標(biāo)決定旋轉(zhuǎn)速度。演示:1、新建Flash文件,設(shè)置寬、高屬性為 550 400 。2、用圓角矩形工具,畫一個(gè) 158 35的長方形。筆觸為8白色,填充色0 F7E 88。圖1下載 (22.67 KB)2010-3-17 08:203、將長方形轉(zhuǎn)換成名為 Menu Item 的影片剪輯。設(shè)定注冊點(diǎn)為中心。圖2下載 (15.34 KB)2010-3-17 08:204、雙擊舞臺(tái)上的影片剪輯,進(jìn)入編輯狀態(tài)。創(chuàng)建動(dòng)態(tài)文本,在它里面輸入需要的本文。圖3下載 (7.57 K
2、B)2010-3-17 08:205、在屬性面板中輸入實(shí)例名字 menuItemText 。6、按下字符嵌入按鈕,插入下列字型。圖4下載 (44.37 KB)2010-3-17 08:207、切換回主場景1,刪除舞臺(tái)上的影片剪輯,實(shí)例將由代碼生成。8、打開庫元件面板,右鍵單擊影片剪輯,(CS3選鏈接、CS4選屬性)給元件添加一個(gè)綁定類。類名 MenuItem 。圖5下載 (23.04 KB)2010-3-17 08:209、選中第1幀,打開動(dòng)作面板輸入代碼: 1. /The total number of menu items2. const NUMBER_OF_ITEMS:uint = 20
3、;3.4. /This array will contain all the menu items5. var menuItems:Array = new Array();6.7. /Set the focal length8. var focalLength:Number = 350;9.10. /Set the vanishing point11. var vanishingPointX:Number = stage.stageWidth / 2;12. var vanishingPointY:Number = stage.stageHeight / 2;13.14. /We calcul
4、ate the angleSpeed in the ENTER_FRAME listener15. var angleSpeed:Number = 0;16.17. /Radius of the circle18. var radius:Number = 128;19.20. /Calculate the angle difference between the menu items (in radians)21. var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;22.23. /This loop cre
5、ates and positions the carousel items24. for (var i:uint = 0; i the smaller the scale ratio)41. var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);42.43. /Scale the menu item according to the scale ratio44. menuItem.scaleX = menuItem.scaleY = scaleRatio;45.46. /Position the menu item to th
6、e stage (from 3D to 2D coordinates)47. menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;48. menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;49.50. /Assign an initial alpha51. menuItem.alpha = 0.3;52.53. /Add a text to the menu item54. menuItem.menuItemText.text = Menu item + i
7、;55.56. /We dont want the text field to catch mouse events57. menuItem.mouseChildren = false;58.59. /Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item60. menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);61. menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem)
8、;62. menuItem.addEventListener(MouseEvent.CLICK, itemClicked);63.64. /Add the menu item to the menu items array65. menuItems.push(menuItem);66.67. /Add the menu item to the stage68. addChild(menuItem);69. 70.71. /Add an ENTER_FRAME listener for the animation72. addEventListener(Event.ENTER_FRAME, mo
9、veCarousel);73.74. /This function is called in each frame75. function moveCarousel(e:Event):void 76.77. /Calculate the angle speed according to mouseY position78. angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;79.80. /Loop through the menu items81. for (var i:uint = 0; i NUMBER_OF_ITEMS; i+)
10、 82.83. /Store the menu item to a local variable84. var menuItem:MenuItem = (MenuItem)(menuItemsi);85.86. /Update the current angle of the item87. menuItem.currentAngle += angleSpeed;88.89. /Calculate a scale ratio90. var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);91.92. /Scale the ite
11、m according to the scale ratio93. menuItem.scaleX=menuItem.scaleY=scaleRatio;94.95. /Set new 3D coordinates96. menuItem.xpos3D=- radius*Math.cos(menuItem.currentAngle)*0.5;97. menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);98. menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);99.100. /U
12、pdate the items coordinates.101. menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;102. menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;103. 104.105. /Call the function that sorts the items so they overlap each other correctly106. sortZ();107. 108.109. /This function sorts the items so the
13、y overlap each other correctly110. function sortZ():void 111.112. /Sort the array so that the item which has the highest 113. /z position (= furthest away) is first in the array114. menuItems.sortOn(zpos3D, Array.NUMERIC | Array.DESCENDING);115.116. /Set new child indexes for the images117. for (var
14、 i:uint = 0; i NUMBER_OF_ITEMS; i+) 118. setChildIndex(menuItemsi, i);119. 120. 121.122. /This function is called when a mouse is over an item123. function mouseOverItem(e:Event):void 124.125. /Change the alpha to 1126. e.target.alpha=1;127. 128.129. /This function is called when a mouse is out of an item130. function mouseOutItem(e:Event):void 131.132. /
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 四年級美術(shù)下冊師資培訓(xùn)計(jì)劃
- 新北師大版三年級數(shù)學(xué)下冊錯(cuò)題復(fù)習(xí)計(jì)劃
- 中學(xué)生健康體育鍛煉一小時(shí)計(jì)劃
- 金蝶KIS專業(yè)版客戶應(yīng)收賬款流程他
- 二年級數(shù)學(xué)下冊教學(xué)評價(jià)計(jì)劃
- 語文教師師徒結(jié)對網(wǎng)絡(luò)學(xué)習(xí)計(jì)劃
- 幼兒園消防安全教育課程計(jì)劃
- 六年級上冊英語培優(yōu)輔差口語提升計(jì)劃
- xx煤礦智能化建設(shè)智能維護(hù)計(jì)劃
- 六年級勞動(dòng)與技術(shù)實(shí)驗(yàn)計(jì)劃
- 興縣煤下鋁開采可行性方案
- 中央廚房食品項(xiàng)目經(jīng)營分析報(bào)告
- 小學(xué)四年級道德與法治期末考試質(zhì)量分析
- 鉗工實(shí)操試卷-共44套
- 論融資租賃資產(chǎn)證券化在我國存在的必要性
- 麻醉藥品精神藥品管理培訓(xùn)課件
- QCC品管圈活動(dòng)表格匯編
- 2023年貴州省社區(qū)工作者公開招聘考試《公共基礎(chǔ)知識》專項(xiàng)題庫【真題精選+章節(jié)題庫+模擬試題】
- 出租車大包車合同
- 銀行副行長個(gè)人簡歷表格
- 第四講 堅(jiān)持以人民為中心PPT習(xí)概論2023優(yōu)化版教學(xué)課件
評論
0/150
提交評論