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.

Example 10-10. VideoWorks.as (continued)<br />

}<br />

}<br />

public function startPlay(ns:NetStream,flv:String):void<br />

{<br />

state.startPlay(ns,flv);<br />

}<br />

public function stopPlay(ns:NetStream):void<br />

{<br />

state.stopPlay(ns);<br />

}<br />

public function setState(state:State):void<br />

{<br />

trace("A new state is set");<br />

this.state=state;<br />

}<br />

public function getState( ):State<br />

{<br />

return state;<br />

}<br />

public function getPlayState( ):State<br />

{<br />

return this.playState;<br />

}<br />

public function getStopState( ):State<br />

{<br />

return this.stopState;<br />

}<br />

In addition to the classes that make up the State design pattern, you will need a copy<br />

of the NetBtn and BtnState classes shown in Example 10-11 and Example 10-12. In<br />

fact, in all the examples in this chapter, the NetBtn.as and BtnState.as files will be<br />

required in the same folder as the other files. In subsequent listings, we didn’t<br />

include the listing for the class because they’re all identical. (That means once you’ve<br />

entered it, you don’t have to do anything else with it.) So keep the files handy, and<br />

make sure that they’re included in the folders with your other classes.<br />

Example 10-11. NetBtn.as<br />

package<br />

{<br />

//Button for transition triggers<br />

import flash.display.Sprite;<br />

import flash.display.SimpleButton;<br />

import flash.display.Shape;<br />

import flash.text.TextFormat;<br />

import flash.text.TextField;<br />

import flash.text.TextFieldAutoSize;<br />

public class NetBtn extends SimpleButton<br />

{<br />

public function NetBtn (txt:String)<br />

370 | Chapter 10: State Pattern

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

Saved successfully!

Ooh no, something went wrong!