O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example: Print Shop

Let's develop an example application to dispatch print jobs at a hypothetical print shop (think copy center with printers). Think of the shop as a place where customers bring what they want to print on portable media. The clerk at the counter will initiate a print job on the computer for dispatch and billing, based on the type of print job. We will build the application in Flash and ActionScript 3.0 as a generic example to illustrate the utility of the factory method pattern.

Our print shop is a small time operation with only two printers. We have a workgroup printer and an inkjet that prints in black and white. In order to streamline operations, the manager has a bright idea to create separate print centers in the shop. One print center will handle high-volume jobs that will be sent to the workgroup printer. The other will handle low-volume jobs that will be dispatched to the inkjet. We design the print shop application using the factory method pattern, as we had heard somewhere that it allows for flexibility and expansion. We are hoping to make a profit and add more printers in the future. Figure 2-5 shows the class structure for the print shop example.

Project window for the print shop example

Figure 2-5. Project window for the print shop example

The class structure is very similar to the minimalist example shown in Figure 2-3. The products will be print jobs that will be created and the creators will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required