
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
14
|
Chapter 2: Object-Oriented ActionScript
Properly applied, OOP adds a level of conceptual organization to a program. It
groups related functions and variables together into separate classes, each of which is
a self-contained part of the program with its own responsibilities. Classes are used to
create individual objects that execute functions and set variables on one another, pro-
ducing the program’s behavior. Organizing the code into classes makes it easier to
create a program that maps well to real-world problems with real-world compo-
nents. Parts II and III of this book cover some of the common situations you’ll
encounter in ActionScript, and show how to apply OOP solutions to them. But
before we explore applied situations, let’s briefly consider the basic concepts of OOP.
Key Object-Oriented Programming Concepts
An object is a self-contained software module that contains related functions (called
its methods) and variables (called its properties). Individual objects are created from
classes, which provide the blueprint for an object’s methods and properties. That is,
a class is the template from which an object is made. Classes can represent theoreti-
cal concepts, such as a timer, or physical entities in a program, such as a pull-down
menu or a spaceship. A single class can ...