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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

site extreme in that it would require a clown to do everything, even if he could only<br />

do two of the tricks.<br />

The Skits Interface and Implementations<br />

The Skits interface (Example 11-13) and its implemented classes (Examples 11-14<br />

and 11-15) are set up exactly the same as the Tricks class and its implementations. It<br />

also has the same limitations.<br />

Example 11-13. Skits.as<br />

package<br />

{<br />

//Skits Interface<br />

interface Skits<br />

{<br />

function skit( ):void;<br />

}<br />

}<br />

Example 11-14. FallDown.as<br />

package<br />

{<br />

//Falls down a ladder<br />

public class FallDown implements Skits<br />

{<br />

public function skit( ):void<br />

{<br />

trace("I'm climbing up this ladder!")<br />

trace("Where's my banana peel?")<br />

trace("Whoaaaa! I'm falling!!")<br />

trace("Thanks for finding my banana peel!\n")<br />

}<br />

}<br />

}<br />

Example 11-15. Chase.as<br />

package<br />

{<br />

//Clowns chase each other<br />

public class Chase implements Skits<br />

{<br />

public function skit( ):void<br />

{<br />

trace("Here I <strong>com</strong>e! I'm going to get you!")<br />

trace("Nah! Nah! Can't catch me!\n")<br />

}<br />

}<br />

}<br />

Adding More Concrete Strategies and Concrete Contexts | 409

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

Saved successfully!

Ooh no, something went wrong!