方法重寫
如果你是一個類,你可以使用 override 關鍵字來定義繼承類定義的方法:
public class Example {
    public function test():void {
        trace('It works!');
    }
}
public class AnotherExample extends Example {
    public override function test():void {
        trace('It still works!');
    }
}
例:
var example:Example = new Example();
var another:AnotherExample = new AnotherExample();
example.test(); // Output: It works!
another.test(); // Output: It still works!
你可以使用 super 關鍵字從正在繼承的類中引用原始方法。例如,我們可以將 AnotherExample.test() 的主體更改為:
public override function test():void {
    super.test();
    trace('Extra content.');
}
導致:
another.test(); // Output: It works!
                //         Extra content.
重寫類建構函式有點不同。省略了 override 關鍵字,只需使用 super() 即可訪問繼承的建構函式:
public class AnotherClass extends Example {
    public function AnotherClass() {
        super(); // Call the constructor in the inherited class.
    }
}
你還可以覆蓋 get 和 set 方法。