extends

Availability

Flash Player 6.

Usage

class className extends otherClassName
interface interfaceName extends otherInterfaceName

Note: To use this keyword, you must specify ActionScript 2 and Flash Player 6 or Flash Player 7 in the Flash tab of your FLA file's Publish Settings dialog box. This keyword is supported only when used in external script files, not in scripts written in the Actions panel.

Description

; defines a class or interface that is a subclass of another class or interface; the latter is the superclass. The subclass inherits all the methods, properties, functions, and so on that are defined in the superclass.

A class can extend no more than one class, and an interface can extend no more than one interface.

If you don't place a call to the superconstructor in the constructor function of a subclass, a call to the constructor of its immediate superclass with no parameters will automatically be inserted as the first statement of the function. However, if the superclass takes parameters in its definition, you must create a constructor in the subclass and call the superclass with the required parameters.

Example

In the class B defined below, a call to class A's superconstructor will automatically be inserted as the first statement of B's constructor function, since a call does not already exist there.

class B extends class A
{
  function B() { // this is the constructor
		super(); // optional; inserted during compilation if omitted
	}
  function m():Number {return 25;}
  function o(s:String):Void {trace(s);}
} 

See also

class, interface