super
Availability
Flash Player 6.
Usage
super.method([arg1, ..., argN])
super([arg1, ..., argN])
Parameters
The method to invoke in the superclass.
method
Optional parameters that are passed to the superclass version of the method (syntax 1) or
arg1
to the constructor function of the superclass (syntax 2).
Returns
Both forms invoke a function. The function can return any value.
Description
Operator: the first syntax style can be used within the body of an object method to invoke the
superclass version of a method and can optionally pass parameters (
superclass method. This is useful for creating subclass methods that add behavior to superclass
methods but also invoke the superclass methods to perform their original behavior.
The second syntax style can be used within the body of a constructor function to invoke the
superclass version of the constructor function and can optionally pass parameters to it. This is
useful for creating a subclass that performs additional initialization but also invokes the superclass
constructor to perform superclass initialization.
Example
In the following example, you create two classes. You use the
call functions in the parent class (Clothes). Although both the Socks and Clothes classes have a
method called
getColor()
and properties. Create a new AS file called Clothes.as, and enter the following code:
class Clothes {
private var color:String;
function Clothes(param_color) {
this.color = param_color;
trace("[Clothes] I am the constructor");
}
function getColor():String {
trace("[Clothes] I am getColor");
return this.color;
}
function setColor(param_color:String):Void {
this.color = param_color;
trace("[Clothes] I am setColor");
}
}
ActionScript Core Language Elements
, using
lets you specifically reference the base class's methods
super
CHAPTER 5
...
) to the
arg1
argN
keyword in the Sock class to
super
super
209
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?