MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference page 812

Actionscript language reference
Table of Contents

Advertisement

Then 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(param_color:String) {
this.color = param_color;
trace("[Socks] I am the constructor");
}
function getColor():String {
trace("[Socks] I am getColor");
return super.getColor();
}
function setColor(param_color:String):Void {
this.color = param_color;
trace("[Socks] I am setColor");
}
}
Then create a new AS or FLA file and enter the following ActionScript in the document:
import Socks;
var mySock:Socks = new Socks("maroon");
trace(" -> "+mySock.getColor());
mySock.setColor("Orange");
trace(" -> "+mySock.getColor());
The following result is displayed in the Output panel:
[Clothes] I am the constructor
[Socks] I am the constructor
[Socks] I am getColor
[Clothes] I am getColor
-> maroon
[Socks] I am setColor
[Socks] I am getColor
[Clothes] I am getColor
-> Orange
If you forgot to put the
method could call itself repeatedly, which would cause the script to fail because of
getColor()
infinite recursion problems. The Output panel would display the following error if you didn't use
the
keyword:
super
[Socks] I am getColor
[Socks] I am getColor
...
[Socks] I am getColor
256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.
812
Chapter 2: ActionScript Language Reference
keyword in the Sock class's
super
method, then the
getColor()

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents