10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example 7-24. Client code for undoable number manipulator<br />

26 panel.setCommand(1, decCommand);<br />

27 panel.setCommand(2, undo);<br />

The example application will look like Figure 7-4 with an additional “Undo” button.<br />

Command “redo” functionality including logging features can be implemented in<br />

similar ways. Logging features are useful when the <strong>com</strong>mands executed need to be<br />

saved on disk. For example, saving the installation <strong>com</strong>mand objects on disk when a<br />

new application is installed will facilitate an uninstall by loading the logged <strong>com</strong>mands<br />

and undoing them in reverse order.<br />

Example: Podcast Radio<br />

This example implements a classic car radio with a twist. Instead of programming<br />

the push buttons to tune to a radio station, they will be attached to <strong>com</strong>mand objects<br />

that will download and play the latest episode from a podcast. Think of this as a<br />

futuristic car radio when long-range Wi-Fi be<strong>com</strong>es a reality. You can listen to the<br />

NPR hourly news summary on demand without waiting for the top of the hour.<br />

Figure 7-5 shows the screen layout of the application. It consists of labeled buttons<br />

that indicate the genre of the podcast assigned to each button, and a text field that<br />

displays the title of the podcast item that is currently playing.<br />

Figure 7-5. Screenshot of podcast radio<br />

What Is a Podcast?<br />

A podcast is a media file that is distributed over the Internet. Podcasts are distributed<br />

using a syndication feed, which is a standard way of distributing content that is<br />

regularly updated. The feed is an XML file just like a syndicated news feed that lists<br />

news stories with the most recent one first. The difference between news feeds and<br />

270 | Chapter 7: Command Pattern

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!