MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference page 298

Actionscript language reference
Table of Contents

Advertisement

The following example shows a second AS file, called Car.as, in the same directory. This class
extends the Vehicle class, modifying it in three ways. First, the Car class adds a variable
fullSizeSpare
method specific to cars,
overrides the
stop()
to stop.
class Car extends Vehicle {
var fullSizeSpare:Boolean;
function Car(param_numDoors:Number, param_color:String,
param_fullSizeSpare:Boolean) {
this.numDoors = param_numDoors;
this.color = param_color;
this.fullSizeSpare = param_fullSizeSpare;
}
function activateCarAlarm():Void {
trace("[Car] activateCarAlarm");
}
function stop():Void {
trace("[Car] stop with anti-lock brakes");
}
}
The following example instantiates a Car object, calls a method defined in the Vehicle class
(
), then calls the method overridden by the Car class (
start()
from the Car class (
var myNewCar:Car = new Car(2, "Red", true);
myNewCar.start(); // output: [Vehicle] start
myNewCar.stop(); // output: [Car] stop with anti-lock brakes
myNewCar.activateCarAlarm(); // output: [Car] activateCarAlarm
See also
class, implements,
298
Chapter 2: ActionScript Language Reference
to track whether the car object has a full-size spare tire. Second, it adds a new
activateCarAlarm()
function to add the fact that the Car class uses an anti-lock braking system
activateCarAlarm()
interface
, that activates the car's anti-theft alarm. Third, it
stop()
):
), and finally calls a method

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?

This manual is also suitable for:

Flash mx

Table of Contents