Flash / Flex / ActionScript/Class/super

Материал из Web эксперт
Перейти к: навигация, поиск

Use super.methodName to call method in the super class

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var rBunny:Rabbit = new Rabbit();
        rBunny.eat();
    }
  }
}
class Mammal {
    public function eat():void {
      trace("mammal");
    }
}
class Rabbit extends Mammal {
    public override function eat():void {
      super.eat();
      trace("rabbit");
    }
}