01 | public class foo{ |
02 | public var f: int ; |
03 | public function foo( f: int ){ |
04 | this .f = f; |
05 | } |
06 | } |
07 |
08 | public class bar extends foo{ |
09 | public var b: int ; |
10 | public function bar( b: int ){ |
11 | this .b = b; |
12 | } |
13 | } |
但在 ActionScript compiler 會告訴你 No default constructor found in base class foo.
也就是說在建構時,子類會自動引用基底類別的 default constructor
OK,這很正常,那我在基底類補上 default constructor 就行了
1 | public class foo{ |
2 | public var f: int ; |
3 | public function foo(){ |
4 | f = 0 ; |
5 | } |
6 | public function foo( f: int ){ |
7 | this .f = f; |
8 | } |
9 | } |
然後這次 compiler 又會告訴你 Multiple constructor definitions found. Constructor may not be defined in <Script/> code.
ActionScript 竟然只允許你擁有一個建構子
結合第一點,表示你根本無法繼承一個擁有非預設建構子的類別(=△=. )