




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、AS3.0 3D旋轉(zhuǎn)木馬效果實例在這個 3D旋轉(zhuǎn)菜單教程中,將學習如何用 AS3 代碼創(chuàng)建一個垂直的 3D立體菜單效果。木馬將會根據(jù)鼠標決定旋轉(zhuǎn)速度。演示:1、新建Flash文件,設(shè)置寬、高屬性為 550 400 。2、用圓角矩形工具,畫一個 158 35的長方形。筆觸為8白色,填充色0 F7E 88。圖1下載 (22.67 KB)2010-3-17 08:203、將長方形轉(zhuǎn)換成名為 Menu Item 的影片剪輯。設(shè)定注冊點為中心。圖2下載 (15.34 KB)2010-3-17 08:204、雙擊舞臺上的影片剪輯,進入編輯狀態(tài)。創(chuàng)建動態(tài)文本,在它里面輸入需要的本文。圖3下載 (7.57 K
2、B)2010-3-17 08:205、在屬性面板中輸入實例名字 menuItemText 。6、按下字符嵌入按鈕,插入下列字型。圖4下載 (44.37 KB)2010-3-17 08:207、切換回主場景1,刪除舞臺上的影片剪輯,實例將由代碼生成。8、打開庫元件面板,右鍵單擊影片剪輯,(CS3選鏈接、CS4選屬性)給元件添加一個綁定類。類名 MenuItem 。圖5下載 (23.04 KB)2010-3-17 08:209、選中第1幀,打開動作面板輸入代碼: 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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 四川外國語大學《化工設(shè)備設(shè)計》2023-2024學年第二學期期末試卷
- 廣東東軟學院《射頻集成電路分析與設(shè)計》2023-2024學年第二學期期末試卷
- 邢臺學院《鋼琴5》2023-2024學年第二學期期末試卷
- 新疆建設(shè)職業(yè)技術(shù)學院《水利水電工程概論》2023-2024學年第二學期期末試卷
- 青海師范大學《數(shù)字高程模型》2023-2024學年第二學期期末試卷
- 江西航空職業(yè)技術(shù)學院《美術(shù)三》2023-2024學年第二學期期末試卷
- 全國閩教版初中信息技術(shù)八年級上冊第一單元《綜合活動1 展評平面設(shè)計作品》教學設(shè)計
- 長春金融高等??茖W?!斗N子生物學》2023-2024學年第二學期期末試卷
- 三峽電力職業(yè)學院《勞動教育2》2023-2024學年第二學期期末試卷
- Unit 2 Good Health to You!(Lesson 9) (教學設(shè)計) -2023-2024學年冀教版(三起)英語六年級下冊
- 月考后正確的試卷分析方法分析研究
- 越野車改裝方案
- 修辭手法在計算機語言學中的應(yīng)用
- 裝修施工規(guī)定(十四篇)
- 消防工程維保方案三篇
- 高考一輪復(fù)習《文學類文本閱讀(小說)》教案
- 空間向量求線面角
- 閱讀與思考圓錐曲線的光學性質(zhì)及其應(yīng)用課件
- 試產(chǎn)到量產(chǎn)項目轉(zhuǎn)移清單
- 城市軌道交通應(yīng)急處理 01 城市軌道交通應(yīng)急處理概述-2
- 2023年全國中學生物理競賽預(yù)賽試題含答案版
評論
0/150
提交評論