
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
214
|
Chapter 6: Inheritance
• Each Shape subclass provides a means of drawing itself to the screen
• External code can safely call draw( ) on any Shape subclass (the compiler will not
let a class extend Shape without implementing draw( ))
Unfortunately, ActionScript 2.0 does not yet support abstract classes or abstract
methods. Instead of defining an abstract method in ActionScript, we simply define a
method with no code in its body. It’s left up to the programmer (not the compiler) to
ensure that the subclasses of a would-be abstract class implement the appropriate
method(s).
In contrast to an abstract method, which must be implemented by a subclass, a final
method is a method that must not be implemented by a subclass; otherwise, a com-
pile-time error occurs. Final methods are used to prevent programmers from creat-
ing subclasses that accidentally introduce problems into the behavior of a superclass
or intentionally sabotage a superclass. Like abstract methods, this useful OOP fea-
ture is not part of ActionScript 2.0 for Flash Player 7, but may be implemented in the
future.
Let’s Try Inheritance
We have studied a lot of theory in this chapter. When you’re ready to see how inher-
itance feels in the real world, move on to the next chapter, where the ImageViewer
class is extended.