User Guide
45
CHAPTER 2
Creating Custom Classes with ActionScript 2.0
ActionScript 2.0 provides several powerful programming features found in other programming
languages, such as Java. ActionScript 2.0 encourages program structures that are reusable,
scalable, robust, and maintainable. It also decreases development time by providing users
thorough coding assistance and debugging information. ActionScript 2.0 conforms more closely
to the ECMA-262 Edition 3 standard (see www.ecma-international.org/publications/standards/
Ecma-262.htm).
The main features of ActionScript 2.0 include the following:
Familiar object-oriented programming (OOP) model The primary feature of
ActionScript 2.0 is a familiar model for creating object-oriented programs. ActionScript 2.0
implements several object-oriented concepts and keywords such as class, interface, and packages
that will be familiar to you if you’ve programmed with Java.
Strict data typing ActionScript 2.0 also lets you explicitly specify data types for variables,
function parameters, and function return types. For example, the following code declares a
variable named
userName of type String (a built-in ActionScript data type, or class).
var userName:String = "";
Compiler warnings and errors
The previous two features (OOP model and strict data typing)
enable the compiler to provide warnings and error messages that help you find bugs in your
applications.
Principles of object-oriented programming
This section provides a brief introduction to principles involved in developing object-oriented
programs. These principles are described in more depth in the rest of this chapter, along with
details on how they are implemented in Macromedia Flex.
To learn about object-oriented programming principles, see the following topics:
• “Objects” on page 46
• “Classes and class members” on page 46
• “Inheritance” on page 46
• “Interfaces” on page 47