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 11-20. ClownCollege.as (continued)<br />

}<br />

{<br />

}<br />

public function ClownCollege( )<br />

{<br />

var joker:Clown=new Koka( );<br />

joker.doTrick( );<br />

joker.doSkit( );<br />

}<br />

var gagGrrrl:Clown=new Bojo( );<br />

gagGrrrl.doTrick( );<br />

gagGrrrl.doSkit( );<br />

var gurgle:Clown=new Bubbles( );<br />

gurgle.doSkit( );<br />

gurgle.doTrick( );<br />

gurgle.setTrick(new BubblePants( ));<br />

gurgle.doTrick( );<br />

Nothing will change for the first two clowns. However, the new clown instance<br />

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

trick involve falling off the ladder and juggling. That is unchanged, and so the new<br />

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

However, after the doTrick( ) method is invoked, the instance, gurgle, is given a new<br />

trick. Then, when the doTrick( ) launches a second time for the gurgle instance, a<br />

different trick display is shown. The bold output in the following output shows the<br />

results of the added materials:<br />

* =>KokaBubbles

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

Saved successfully!

Ooh no, something went wrong!