The last important concept of object-oriented programming that we want to discuss is polymorphism. This is the ability to execute methods of a subclass just like you would execute the same methods in its superclass. For example, you may have worked hard developing a robust vehicle class that includes steps necessary to move the vehicle. Having done so, it's less advantageous to use separate method names, perhaps "drive," "pilot," and "fly," to accomplish the same task of moving a car, boat, and plane.
Instead, a universal method name that would apply in all of these described scenarios, such as "move," would be preferable. This is referred to as override polymorphism because somewhat customized steps to move a car, boat, and plane each override the more general steps used to enable movement of a generic vehicle.
Another example to consider is the x coordinate of a display
object. In Chapter 4, you learned that many
display objects, like movie clip, sprite, and button, descend from the
same parent. Much of their functionality overlaps, including the
ability to set the x coordinate of each display object. Imagine,
however, if you had to specify separate properties for each display
type to accomplish this same goal. For example, imagine if you had to
write "spriteX," "movieClipX," and "buttonX," instead of just
x. Even though these display objects all have different data types, polymorphism allows you to use the same method to control a particular behavior of all the class ...