override method from parent class
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var c:Cat = new Cat();
c.speak("Miao");
}
}
}
class Animal {
public function Animal() {
}
public function speak(sound:String):void {
trace(sound);
}
}
class Cat extends Animal {
public function Cat() {
}
public override function speak(sound:String):void {
for (var i:uint=0; i < 100; i++) {
super.speak("Meow! Meow! Meow!");
}
}
}
Related examples in the same category