Classes - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

CHAPTER 4
4
Object-Oriented
Programming in ActionScript
This chapter assumes a basic understanding of object-oriented programming (OOP)
principles such as abstraction, encapsulation, inheritance, and polymorphism. The chapter
focuses on how to apply these principles using ActionScript 3.0.
Because of ActionScript's roots as a scripting language, ActionScript 3.0 OOP support is
optional. This affords programmers flexibility in choosing the best approach for projects of
varying scope and complexity. For small tasks, you may find that using ActionScript with a
procedural programming paradigm is all you need. For larger projects, applying OOP
principles can make your code easier to understand, maintain, and extend.
Contents
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Example: GeometricShapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Classes

A class is an abstract representation of an object. A class stores information about the types of
data that an object can hold and the behaviors that an object can exhibit. The usefulness of
such an abstraction may not be apparent when you write small scripts that contain only a few
objects interacting with one another. As the scope of a program grows, however, and the
number of objects that must be managed increases, you may find that classes allow you to
better control how objects are created and how they interact with one another.
107

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents