ActionScript 3.0 Design Patterns

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

Nothing will change for the first two clowns. However, the new clown instance


should do something different, but what? In looking at the code, the initial skit and


trick involve falling off the ladder and juggling. That is unchanged, and so the new


clown’s initial displays should be no different than anything you’ve seen so far.


However, after thedoTrick( )method is invoked, the instance,gurgle, is given a new


trick. Then, when thedoTrick( )launches a second time for thegurgleinstance, a


different trick display is shown. The bold output in the following output shows the


results of the added materials:


* =>Koka<= *
Now you see it! Presto! It's gone!

Here I come! I'm going to get you!
Nah! Nah! Can't catch me!

* =>Bojo<= *
See! It's a doggy! No, it's not that!!

I'm climbing up this ladder!
Where's my banana peel?
Whoaaaa! I'm falling!!
Thanks for finding my banana peel!

* =>Bubbles<= *
I'm climbing up this ladder!
Where's my banana peel?
Whoaaaa! I'm falling!!
Thanks for finding my banana peel!

Look at me juggle! Whoops!

Woo woo woo! Bubbles are coming out of my pants!

{

public function ClownCollege( )
{
var joker:Clown=new Koka( );
joker.doTrick( );
joker.doSkit( );


var gagGrrrl:Clown=new Bojo( );
gagGrrrl.doTrick( );
gagGrrrl.doSkit( );


var gurgle:Clown=new Bubbles( );
gurgle.doSkit( );
gurgle.doTrick( );
gurgle.setTrick(new BubblePants( ));
gurgle.doTrick( );
}
}
}


Example 11-20. ClownCollege.as (continued)

Free download pdf