ABSTRACT

Fruit – A Superclass If inheritance is a new concept, then it may be helpful to think about it in familiar terms. The concept of class inheritance is actually familiar to everyone, but the terminology may not be. Take fruit, for example. The word “fruit” refers to a class of objects that are – among other things – edible. To adequately describe a fruit, a number of properties are required. Some (unscientific) fruit properties include:

These informal properties apply to all fruit: apples, oranges, bananas, grapes, etc. But apples have properties that bananas don’t have, including:

And grapes have properties that neither apples, nor bananas have:

The analogy can only go so far. Real fruit are more complex than any AS2 class will ever be, but the properties and relationships defined above can be described in AS2 terms. The code for a (whimsical) Fruit class would look something like the code in Listing 11.1.