ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Paperback)

William Sanders, Chandima Cumaranatunge




Now that ActionScript is reengineered from top to bottom as a true object-oriented programming (OOP) language, reusable design patterns are an ideal way to solve common problems in Flash and Flex applications. If you're an experienced Flash or Flex developer ready to tackle sophisticated programming techniques with ActionScript 3.0, this hands-on introduction to design patterns is the book you need.

ActionScript 3.0 Design Patterns takes you step by step through the process, first by explaining how design patterns provide a clear road map for structuring code that actually makes OOP languages easier to learn and use. You then learn about various types of design patterns and construct small abstract examples before trying your hand at building full-fledged working applications outlined in the book. Topics in ActionScript 3.0 Design Patterns include:
  • Key features of ActionScript 3.0 and why it became an OOP language
  • OOP characteristics, such as classes, abstraction, inheritance, and polymorphism
  • The benefits of using design patterns
  • Creational patterns, including Factory and Singleton patterns
  • Structural patterns, including Decorator, Adapter, and Composite patterns
  • Behavioral patterns, including Command, Observer, Strategy, and State patterns
  • Multiple design patterns, including Model-View-Controller and Symmetric Proxy designs
During the course of the book, you'll work with examples of increasing complexity, such as an e-business application with service options that users can select, an interface for selecting a class of products and individual products in each class, an action game application, a video record and playback application, and many more. Whether you're coming to Flash and Flex from Java or C++, or have experience with ActionScript 2.0, ActionScript 3.0 Design Patterns will have you constructing truly elegant solutions for your Flash and Flex applications in no time.

Table of Contents


Part I. Constant Change

1. Object-Oriented Programming, Design Patterns, and ActionScript 3.0

     The Pleasure of Doing Something Well

     OOP Basics





     Principles of Design Pattern Development

     Program to Interfaces over Implementations

     Favor Composition

     Maintenance and Extensibility Planning

     Your Application Plan: It Ain't You Babe

Part II. Creational Patterns

2. Factory Method Pattern

     What Is the Factory Method Pattern?

     Abstract Classes in ActionScript 3.0

     Minimalist Example

     Hiding the Product Classes

     Example: Print Shop

     Extended Example: Color Printing

     Key OOP Concepts Used in the Factory Method Pattern

     Example: Sprite Factory

     Example: Vertical Shooter Game


3. Singleton Pattern

     What Is the Singleton Pattern?

     Key OOP Concepts Used with the Singleton Pattern

     Minimalist Abstract Singleton

     When to Use the Singleton Pattern


Part III. Structural Patterns

4. Decorator Pattern

     What Is the Decorator Pattern?

     Key OOP Concepts Used with the Decorator Pattern

     Minimalist Abstract Decorator

     Applying a Simple Decorator Pattern in Flash: Paper Doll

     Decorating with Deadly Sins and Heavenly Virtues

     Dynamic Selection of Concrete Components and Decorations: A Hybrid Car Dealership


5. Adapter Pattern

     What Is the Adapter Pattern?

     Object and Class Adapters

     Key OOP Concepts in the Adapter Pattern

     Example: Car Steering Adapter

     Extended Example: Steering the Car Using a Mouse

     Example: List Display Adapter

     Extended Example: Displaying the O'Reilly New Books List


6. Composite Pattern

     What Is the Composite Pattern?

     Minimalist Example of a Composite Pattern

     Key OOP Concepts in the Composite Pattern

     Example: Music Playlists

     Example: Animating Composite Objects Using Inverse Kinematics

     Using Flash's Built-in Composite Structure: the Display List


Part IV. Behavioral Patterns

7. Command Pattern

     What Is the Command Pattern?

     Minimalist Example of a Command Pattern

     Key OOP Concepts in the Command Pattern

     Minimalist Example: Macro Commands

     Example: Number Manipulator

     Extended Example: Sharing Command Objects

     Extended Example: Implementing Undo

     Example: Podcast Radio

     Extended Example: Dynamic Command Object Assignment


8. Observer Pattern

     What Is the Observer Pattern?

     Key OOP Concepts Used with the Observer Pattern

     Minimalist Abstract Observer

     Example: Adding States and Identifying Users

     Dynamically Changing States

     Example: Working with Different Data Displays


9. Template Method Pattern

     What Is the Template Method Pattern?

     Key OOP Concepts Used with the Template Method

     Minimalist Example: Abstract Template Method

     Employing Flexibility in the Template Method

     Selecting and Playing Sound and Video

     Hooking It Up


10. State Pattern

     Design Pattern to Create a State Machine

     Key OOP Concepts Used with the State Pattern

     Minimalist Abstract State Pattern

     Video Player Concrete State Application

     Expanding the State Design: Adding States

     Adding More States and Streaming Capabilities


11. Strategy Pattern

     What Is the Strategy Pattern?

     Key OOP Concepts Used with the Strategy Pattern

     Minimalist Abstract State Pattern

     Adding More Concrete Strategies and Concrete Contexts

     Working with String Strategies


Part V. Multiple Patterns

12. Model-View-Controller Pattern

     What Is the Model-View-Controller (MVC) Pattern?

     Communication Between the MVC Elements

     Embedded Patterns in the MVC

     Minimalist Example of an MVC Pattern

     Key OOP Concepts in the MVC Pattern

     Example: Weather Maps

     Extended Example: Infrared Weather Maps

     Example: Cars

     Custom Views

     Adding a Chase Car


13. Symmetric Proxy Pattern

     Simultaneous Game Moves and Outcomes

     The Symmetric Proxy Pattern

     Key OOP Concepts Used with the Symmetric Proxy

     The Player Interface

     The Referee

     Information Shared Over the Internet

     Player-Proxy Classes

     Classes and Document Files Support