408 | Chapter 11: Strategy Pattern
By using a general concept like “tricks,” we’re limiting the range of what the clowns
can do. The way the Strategy pattern’s set up, each clown can have only a single
trick. We could implement an “All Tricks” class, but that’s too broad at the oppo-
interface Tricks
{
function trick( ):void;
}
}
Example 11-10. BalloonAnimals.as
package
{
//Make Balloon Animals
public class BalloonAnimals implements Tricks
{
public function trick( ):void
{
trace("See! It's a doggy! No, it's not an elephant!!\n")
}
}
}
Example 11-11. Disappear.as
package
{
//Make Something Disappear
public class Disappear implements Tricks
{
public function trick( ):void
{
trace("Now you see it! Presto! It's gone!\n")
}
}
}
Example 11-12. Juggle.as
package
{
//Juggle Balls
public class Juggle implements Tricks
{
public function trick( ):void
{
trace("Look at me juggle! Whoops!\n")
}
}
}
Example 11-9. Tricks.as (continued)