Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. Factory Method Pattern > Minimalist Example

Minimalist Example

We will develop a minimalist example of a factory method pattern in ActionScript 3.0 using Flash CS3. The Project window shown in Figure 2-3 mirrors the file structure for the example.

Project window for the minimalist example
Figure 2-3. Project window for the minimalist example

The Factory Method Minimalist.fla is a Flash document whose document class is defined as Main. The document class is a new feature in Flash CS3 that can be set from the Properties tab in the Properties panel of a Flash document (.fla file). This represents the class whose constructor will be automatically run by the Flash Player when the Flash movie (.swf file) is loaded. The Main class is defined in the ActionScript file called Main.as. The project also contains a package called example. Packages allow you to bundle classes together to facilitate code sharing. They also allow control over the visibility of classes and method names outside the package by using identifiers. This minimizes naming conflicts that can occur when developing applications. We will use packages to hide the product classes from direct access by clients in this example.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint