1 / 24

ActionScript 3 簡介

ActionScript 3 簡介. 鄧姚文. 教材與參考書. 李篤易 ( 2012 ), 大師級 ! Flash 遊戲設計創意發想與經典入門, 碁峰資訊股份有限公司, ISBN 9789862765333 (書號 AEG000700 ) 趙英傑 ( 2011 ), ACA 國際認證 -- Flash CS5 數位媒體設計與網站動畫, 碁峰資訊股份有限公司, ISBN 9789862763513 (書號 AER035331 )

tatum
Télécharger la présentation

ActionScript 3 簡介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ActionScript 3 簡介 鄧姚文

  2. 教材與參考書 李篤易 (2012), 大師級! Flash遊戲設計創意發想與經典入門, 碁峰資訊股份有限公司, ISBN 9789862765333 (書號 AEG000700) 趙英傑 (2011), ACA 國際認證 -- Flash CS5 數位媒體設計與網站動畫, 碁峰資訊股份有限公司, ISBN 9789862763513 (書號 AER035331) 張仁川 (2010), Flash CS5創意動畫設計白皮書, 碁峰資訊股份有限公司, ISBN 9789861819969 (書號 AEU009200) 羅智軒 (2011), Flash & ActionScript 3.0 絕對出色影音動畫與互動媒體設計, 碁峰資訊股份有限公司, ISBN 9789862762615 (書號 AEU009900)

  3. ActionScript 簡介 • ActionScript第三版,簡稱 AS3 • 英文字母大小寫視為不同 Case Sensitive!

  4. 套件 package • 將程式碼組織成不連續的群組 • 可以匯入其他程式碼之中 • 成員: • 類別

  5. 類別 class • 物件的定義 • 方法 • 屬性 • 實體化 • class  instance

  6. 實體 instance • 建立實體 • 將元件庫內的元件拖曳至舞台區 • 藉由 new:類別建立實體 • 每一個實體為一個獨立的物件

  7. 事件 event • 事件  事件偵聽處理函數 • Event  Event Handler • 偵聽:Listen • The Observer Pattern(觀察者)

  8. sprite • 作為容器 • 顯示物件 • 類似影片片段,但是沒有時間軸

  9. 資料類型與變數 • 基本:單一資訊 • 數值 Numeric • 字串 String • 布林 Boolean • Null • void • 複雜 • MovieClip、TextField、Array、Date、Error、Function、RegExp、XML、XMLList、…

  10. 資料類型與變數 constx_num:int = 7; varfirst_bk_x:Number= 92.5; • 宣告變數 var • 宣告常數 const • 數值 Numeric • 整數 int • 正整數 uint • 任意數字,包括小數:Number

  11. 資料類型與變數 • 字串 String • 以 "雙引號" 標示 • 以 UTF-16 格式儲存為 Unicode • 一個中文字是一個字元 • 布林 Boolean • 真 true • 假 false

  12. 資料類型與變數 • Null: • 值:null • 複雜資料類型和 String 實體的預設值 • void • 值:undefined • 定義沒有傳回值的函數 • 可以省略

  13. 變數 varvariableName[:dataType1][=value1][...,variableNameN[:dataTypeN][=valueN]] • 用途:程式執行期間暫存資料 • 任何變數在使用前都必須先宣告 • 變數有效範圍 • 僅限宣告該變數的區域 • 不能跨區域、不能跨層級、不能跨函數 • 跨區域的變數(全域變數)必須宣告在主場景的時間軸影格(最上層)

  14. 常數 constx_num:int = 7; consty_num:int = 10; 初值化之後,不可以再改變 以 const宣告

  15. 運算式與運算子 • 運算式(expression) • 運算元(operand) • 變數、常數 • 運算子(operator) • 指定 = • 單一 n++ • 二元 a + b

  16. 流程控制 if (condition) { // condition true 程式區段 } else { // condition false 程式區段 } if (condition1) { // condition1 true 程式區段 } else if (condition2) { // condition2 true 程式區段 .................... } else { // 以上皆非 程式區段 } 選擇 if else

  17. 流程控制 switch (condition) { case value1: // condition==value1 程式區段 break; case value2: // condition==value2 程式區段 break; ............................. [default] // 以上皆非 程式區段 } 選擇 switch case

  18. 迴圈結構 for (init; condition; next) { // 重複的程式區段 } • for 迴圈 • 初值化 init • 迴圈繼續的條件 condition • 下一圈 next • 迴圈每一回合結束後,執行 next

  19. 迴圈結構 while (condition) { // 重複的程式區段 [break;] [continue;] } • while 迴圈 • 中斷迴圈 break • 立即進入下一回合 continue

  20. 函數 function functionName([parameter1, parameter2, ...]): returnType { // 區段程式碼 [return returnValue;] } 可以重複使用的程式區段 提供不同的參數調整行為

  21. 事件 eventTarget.addEventListener(EventType.EVENT_NAME, eventResponse); function eventResponse(eventObject:EventType):void { // 程式區段 } 事件偵聽處理函數 AS 3 不能像 AS2 直接在按鈕上定義事件 只能在關鍵影格內撰寫程式碼

  22. 識別名稱

  23. 方塊遊戲範例 • 選項按鈕 • 單一方塊:單一方塊變顏色 • 垂直行:整行變顏色 • 水平列:整列變顏色 • 鍵盤操作:以鍵盤移動空白方塊

  24. 方塊遊戲範例

More Related