• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 22. ActionScript: Work with Obje... > Create two objects from the Product ...

Create two objects from the Product class

You’ll create a new FLA file, and then create two objects from the Product class.

1.
Open a new Flash document and save it in the same location where you saved Product.as.

2.
In the new document, select Frame 1 in the Timeline.

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).

Instance nameData 
pedalsid0
 prodNameClipless Pedals
 descriptionExcellent cleat engagement
handleBarsid1
 prodNameATB
 descriptionAvailable in comfort and aero design


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.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint