7.2 The ImageViewerDeluxe Skeleton

 <  Day Day Up  >  

The bare bones of any subclass requires:

  • A class declaration that defines the inheritance relationship

  • A constructor that invokes the superclass constructor with the expected arguments

Hence, our ImageViewerDeluxe class starts out with the skeleton shown in Example 7-1. Refer to Example 5-8 for the ImageViewer class definition.

Example 7-1. The ImageViewerDeluxe class skeleton
 /**  * The ImageViewerDeluxe class skeleton   */ class ImageViewerDeluxe extends ImageViewer {   public function ImageViewerDeluxe (target:MovieClip,                                  depth:Number,                                  x:Number,                                  y:Number,                                  w:Number,                                  h:Number,                                 borderThickness:Number,                                 borderColor:Number) {      // Invoke the   ImageViewer   constructor from Example 5-8     super(target, depth, x, y, w, h, borderThickness, borderColor);   } } 

Our ImageViewerDeluxe class does not alter the way an ImageViewer instance is constructed . It merely preserves the ImageViewer class constructor's behavior by accepting the same arguments as the ImageViewer constructor and forwarding them to it via super( ) .

To create the ImageViewerDeluxe.as class file using Flash MX Professional 2004, follow these steps:

  1. Choose File New.

  2. In the New Document dialog box, on the General tab, for Type, choose ActionScript File.

  3. Click OK. The script editor launches with an empty file.

  4. Copy the code from Example 7-1 into the script editor.

  5. Choose File Save As.

  6. In the Save As dialog box, specify ImageViewerDeluxe.as as the filename (which is case sensitive), and save the file in the imageviewer folder that you created in Chapter 5.

Already, our ImageViewerDeluxe class is ready for use. Instances of the ImageViewerDeluxe class have all the ImageViewer class's methods and can be used anywhere ImageViewer instances are used.

 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net