Implementing Subclass Versions of Superclass Methods : Polymorphism : Class Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Class » Polymorphism »

 

Implementing Subclass Versions of Superclass Methods


 

By default, Subclass inherits the toString( ) method as it's implemented in Superclass:

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:Subclass = new Subclass(  );
        
        trace(example.toString(  ))// Displays: Superclass.toString(  )

    }
  }
}
class Superclass {
        public function Superclass(  ) {}
        public function toString(  ):String {
            return "Superclass.toString(  )";
        }
    }

class Subclass extends Superclass {
        public function Subclass(  ) {}
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Class
» Polymorphism