Specifications
Learn about extending existing classes 263
3. In the Actions panel, create two objects from the Product class using the
data shown in the following table (the ActionScript that you’ll create
appears after the table).
4. Verify that you created the objects as follows:
var handleBars:Product = new Product (1, "ATB",
"Available in comfort and aero design");
var pedals:Product=new Product(0,"Clipless
Pedals","Excellent cleat engagement");
5.
Trace the description property of pedals:
trace (pedals.getDescription ());
6.
Save and test the document.
You should see the description of pedals in the Output panel.
Learn about extending existing
classes
The extends keyword in ActionScript 2.0 allows you to use all the
methods and properties of an existing class in a new class. For example, if
you wanted to define a class called Drag that inherited everything from the
MovieClip class, you could use the following:
class Drag extends MovieClip
{}
Instance
name
Data
pedals id 0
prodName Clipless Pedals
description Excellent cleat engagement
handleBars id 1
prodName ATB
description Available in comfort and aero
design
NOTE
A finished sample file of the document you just created, named
handson2.fla, is located in your finished files folder. For the path, see “Set
up your workspace” on page 256.