# super

#### Availability

Flash Player 6.

#### Usage

    super.method([arg1, ..., argN])
    super([arg1, ..., argN])

#### Parameters

`method` The method to invoke in the superclass.

`arg1` Optional parameters that are passed to the superclass version of the method (syntax 1) or to the constructor function of the superclass (syntax 2).

#### Returns

Both forms invoke a function. The function may return any value.

#### Description

Operator: the first syntax style may be used within the body of an object method to invoke the superclass version of a method, and can optionally pass parameters (`arg1` ... `argN`) to the superclass method. This is useful for creating subclass methods that add additional behavior to superclass methods, but also invoke the superclass methods to perform their original behavior.

The second syntax style may be used within the body of a constructor function to invoke the superclass version of the constructor function and may optionally pass it parameters. This is useful for creating a subclass that performs additional initialization, but also invokes the superclass constructor to perform superclass initialization.

#### Example

The following example creates two classes, ParentClass and ChildClass, and defines a method called `method` for each class. Each definition of method has a `trace` action that sends a message to the Output window. The second-to-last line of code creates an instance of the ChildClass and calls its `method` method:

    function ParentClass() {
    }
    ParentClass.prototype.method = function () {
      trace("ParentClass implementation of method");
    };
    function ChildClass() {
    }
    ChildClass.prototype = new ParentClass();
    ChildClass.prototype.method = function () {
      trace("ChildClass implementation of method");
      super.method();
    };
    x = new ChildClass();
    x.method();

The following is displayed in the Output window:

    ChildClass implementation of method
    ParentClass implementation of method

The following example passes parameters to the super constructor:

    function SuperClass(arg){
    	trace("SuperClass constructor was passed " + arg);
    }
    function SubClass(arg){
    	super(arg);
    	trace("SubClass constructor");
    }
    SubClass.prototype = new SuperClass();
    x = new SubClass("test");