If a subclass does not define a constructor, ActionScript automatically creates one and adds a super call as its only statement. : Inheritance  « Class « Flash / Flex / ActionScript






If a subclass does not define a constructor, ActionScript automatically creates one and adds a super call as its only statement.

 

class B extends A {
  public function B (  ) {
    super(  );
  }
}

class B extends A {
}



class Rectangle {
  protected var w = 0;
  protected var h = 0;

  public function Rectangle (width, height) {
    setSize(width, height);
  }

  public function setSize (newW, newH) {
    w = newW;
    h = newH;
  }

  public function getArea (  ) {
    return w * h;
  }
}

class Square extends Rectangle {
  public function Square (side) {
    super(side, side);
  }

  override public function setSize (newW, newH) {
    if (newW == newH) {
      super.setSize(newW, newH);
    }
  }
}

        








Related examples in the same category

1.Extends the super class
2.A Primer on Inheritance
3.Add new method to the children class
4.Three-level inheritance
5.Static Methods and Static Variables Not Inherited
6.Constructor Methods in Subclasses
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: