ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Adding More Concrete Strategies and Concrete Contexts | 409

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


do two of the tricks.


The Skits Interface and Implementations


TheSkitsinterface (Example 11-13) and its implemented classes (Examples 11-14


and 11-15) are set up exactly the same as theTricksclass and its implementations. It


also has the same limitations.


Example 11-13. Skits.as


package
{
//Skits Interface
interface Skits
{
function skit( ):void;
}
}


Example 11-14. FallDown.as


package
{
//Falls down a ladder
public class FallDown implements Skits
{
public function skit( ):void
{
trace("I'm climbing up this ladder!")
trace("Where's my banana peel?")
trace("Whoaaaa! I'm falling!!")
trace("Thanks for finding my banana peel!\n")
}
}
}


Example 11-15. Chase.as


package
{
//Clowns chase each other
public class Chase implements Skits
{
public function skit( ):void
{
trace("Here I come! I'm going to get you!")
trace("Nah! Nah! Can't catch me!\n")
}
}
}

Free download pdf