Add new method to the children class : Inheritance  « Class « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » Class » Inheritance  
Add new method to the children class
 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var bInstance = new B(  );
        bInstance.m();       // Displays: Method m(  ) was called
        bInstance.n();       // Displays: Method n(  ) was called
        trace(bInstance.v);  // Displays: 10


    }
  }
}
class {
  public var v = 10;

  public function (  ) {
    trace("Method m(  ) was called");
  }
}

class extends {
  public function (  ) {
    trace("Method n(  ) was called");
  }
}

Method m(  ) was called
Method n(  ) was called
10

        
Related examples in the same category
1.Extends the super class
2.A Primer on Inheritance
3.Three-level inheritance
4.Static Methods and Static Variables Not Inherited
5.Constructor Methods in Subclasses
6.If a subclass does not define a constructor, ActionScript automatically creates one and adds a super call as its only statement.
7.Call super constructor with parameter
8.Class Scope: Code placed at the top-level of a class body resides in that class's scope.
9.You can call the superclass implementation from the subclass implementation using the super keyword to reference the superclass:
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.