MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 194

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

The following example shows the contents of a file called Vehicle.as, which defines the Vehicle
class:
class Vehicle {
var numDoors:Number;
var color:String;
function Vehicle(param_numDoors:Number, param_color:String) {
this.numDoors = param_numDoors;
this.color = param_color;
}
function start():Void {
trace("[Vehicle] start");
}
function stop():Void {
trace("[Vehicle] stop");
}
function reverse():Void {
trace("[Vehicle] reverse");
}
}
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
to track whether the car object has a full-size spare tire. Second, it adds a new
fullSizeSpare
method specific to cars,
it overrides the
stop()
system 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");
}
}
194
ActionScript language elements
activateCarAlarm()
function to add the fact that the Car class uses an anti-lock braking
, that activates the car's anti-theft alarm. Third,

Advertisement

Table of Contents
loading

Table of Contents