MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 757

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

About the super prefix
If you refer to a method in the parent class, prefix the method with
developers know from where the method is invoked. The following ActionScript 2.0 snippet
demonstrates the use of proper scoping by using the
In the following example, you create two classes. You use the
to call functions in the parent class (Clothes). Although both the Socks and Clothes classes
have a method called
methods and properties. Create a new AS file called Clothes.as, and enter the following code:
class Clothes {
private var color:String;
function Clothes(paramColor) {
this.color = paramColor;
trace("[Clothes] I am the constructor");
}
function getColor():String {
trace("[Clothes] I am getColor");
return this.color;
}
function setColor(paramColor:String):Void {
this.color = paramColor;
trace("[Clothes] I am setColor");
}
}
Create a new class called Socks that extends the Clothes class, as shown in the
following example:
class Socks extends Clothes {
private var color:String;
function Socks(paramColor:String) {
this.color = paramColor;
trace("[Socks] I am the constructor");
}
function getColor():String {
trace("[Socks] I am getColor");
return super.getColor();
}
function setColor(paramColor:String):Void {
this.color = paramColor;
trace("[Socks] I am setColor");
}
}
, using
getColor()
super
super
prefix:
super
keyword in the Socks class
super
lets you specifically reference the base class's
ActionScript coding conventions
so that other
757

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents