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 1-47. Mp3.as (continued)<br />

}<br />

}<br />

public function Mp3( )<br />

{<br />

//Inherits <strong>com</strong>position references from superclass<br />

playMedia = new PlayAudio( );<br />

recordMedia = new RecordAudio( );<br />

}<br />

Example 1-48. PlayMedia.as<br />

package<br />

{<br />

//Interface for playing media<br />

interface PlayMedia<br />

{<br />

function playNow( ):void;<br />

}<br />

}<br />

Example 1-49. PlayVideo.as<br />

package<br />

{<br />

//Concrete PlayMedia: Video<br />

class PlayVideo implements PlayMedia<br />

{<br />

public function playNow( ):void<br />

{<br />

trace("Playing my video. Look at that!");<br />

}<br />

}<br />

}<br />

Example 1-50. PlayAudio.as<br />

package<br />

{<br />

//Concrete PlayMedia: Audio<br />

class PlayAudio implements PlayMedia<br />

{<br />

public function playNow( ):void<br />

{<br />

trace("My MP3 is cranking out great music!");<br />

}<br />

}<br />

}<br />

54 | Chapter 1: Object-Oriented Programming, <strong>Design</strong> <strong>Patterns</strong>, and <strong>ActionScript</strong> <strong>3.0</strong>

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

Saved successfully!

Ooh no, something went wrong!