1.函數 函數語句定義法: function testAdd(a:int, b:int):int{return a+b;} 函數運算式定義法: var test:Function = function(a:int, b:int):int{return a+b;} 1.1函數預設參數 function test(a:int = 3,b:int=2,c:int=1):void { trace(a+b+c,a,b,c); } test();//6,3,2,1 test(9);//12,9,2,1 test(2,9)//12,2,9,1 2.靜態屬性和方法 static var 屬性:屬性類型; public static var 屬性:屬性類型 = 值; static const 屬性:屬性類型 = 值; (常數就要先付予值) static function 方法(參數):返回值類型{} public static function 方法(參數):返回值類型{} 透過實例來存取靜態成員會出錯 var foo:StaticSample = new StaticSample(); // new了foo實例 trace(foo.CLASSNAME); // 在StaticSample類別中有宣告一個靜態成員CLASSNAME foo.hello(); //方法也是一樣 3.構造函數 package { import flash.display.Sprite; public class SampleConstructor extends Sprite { public function SampleConstructor() { var foo:Foo = new Foo(); trace(foo); //輸出:[object Foo] var bar:Bar = new Bar("ActionScript3.0"); //輸出Bar's counstructor! //init executed! //可以看出Bar一建立時,就執行了構造韓數中的語句 trace(bar); //輸出:[object Bar] ...