ActionScript 3.0 Design Patterns

(Chris Devlin) #1

12 | Chapter 1: Object-Oriented Programming, Design Patterns, and ActionScript 3.0


skills that would provide the concrete details for each position. For example, one


programmer may have PHP middleware skills and/or MySQL database skills, while


another may be experienced in using ASP.NET, C# and MS SQL. The abstraction is


in the job description and the details are provided by the applicants’ unique sets of


skills and experience.


InObject-Oriented Design with Applications(Benjamin/Cummings), Grady Booch,


one of the design pattern pioneers, provides the following definition of an abstrac-


tion that is both clear and succinct:


An abstraction denotes the essential characteristics of an object that distinguish it from
all other kinds of object and thus provide crisply defined conceptual boundaries, rela-
tive to the perspective of the viewer.

Booch’s definition pretty well describes the two job descriptions. The descriptions


provide the essential characteristics of the position and they distinguish one from the


other.


Abstractions in ActionScript 3.0


Turning now to abstractions in ActionScript programming, we’ll take a simple video


player for an example. This player will be made of certain elements that we need; so


we start by listing them as abstractions:



  • A Net connection

  • A video screen

  • A stream

  • An FLV file to play


If we put these together just right, we’ll be able to play a video. However, instead of


starting with an abstraction, we want to start with something concrete that works for


us right away. Enter the code in Example 1-2 saving the file using the name in the


caption:


Throughout the book, with a few exceptions, caption names repre-
sent the name used for the file.

Example 1-2. PlayVideo.as


package
{
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.display.Sprite;


public class PlayVideo extends Sprite

Free download pdf