The following sections use the analogy of a cat, demonstrating how cats might compare to
OOP concepts.
Objects
Think of a real-world object, such as a cat. A cat could be said to have properties (or states),
such as name, age, and color; a cat also has behaviors such as sleeping, eating, and purring. In
the world of OOP, objects also have properties and behaviors. Using object-oriented
techniques, you can model a real-world object (such as a cat) or a more abstract object (such as
a chemical process).
The word behaviors is used generically here and does not refer to the Behaviors panel in
the Flash authoring environment.
For more information on objects, see
Instances and class members
Continuing with the real-world analogy of a cat, consider that there are cats of different
colors, ages, and names, with different ways of eating and purring. But despite their individual
differences, all cats are members of the same category, or in OOP terms, the same class: the
class of cats. In OOP terminology, each individual cat is said to be an instance of the Cat class.
Likewise in OOP, a class defines a blueprint for a type of object. The characteristics and
behaviors that belong to a class are jointly referred to as members of that class. The
characteristics (in the cat example, the name, age, and color) are called properties of the class
and are represented as variables; the behaviors (play, sleep) are called methods of the class and
are represented as functions.
For more information on instances and class members, see
on page 250
and
"Using class members" on page
Inheritance
One of the primary benefits of OOP is that you can create subclasses of (or extend) a class; the
subclass then inherits all the properties and methods of the class. The subclass typically
defines additional methods and properties or overrides methods or properties defined in the
superclass. Subclasses can also override (provide their own definitions for) methods defined in
a superclass.
232
Classes
"Object data type" on page
254.
78.
"About class members"
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?