ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Adding More States and Streaming Capabilities | 391

The test module, Example 10-27, that follows in theTestFMS.asclass is a bit more


robust than the previous testing classes used. (In fact it would have probably been a


good idea to break it down into its own class set, but we’re focusing on using it to


demonstrate the State design pattern, and so a humbler test class emerged.) Be sure


to place a copy of theNetBtn.asandBtnState.asfiles in the folder where you’re sav-


ing the rest of your files for this application.


63 }

64 public function getPauseState ( ):State
65 {
66 return this.pauseState;
67 }
68 public function getStopState ( ):State
69 {
70 return this.stopState;
71 }
72 }
73 }

Example 10-27. TestFMS.as


1 package
2 {
3 //Test Module #8
4 import flash.display.Sprite;
5 import flash.net.NetConnection;
6 import flash.net.NetStream;
7 import flash.net.ObjectEncoding;
8 import flash.media.Video;
9 import flash.media.Camera;
10 import flash.media.Microphone;
11 import flash.text.TextField;
12 import flash.text.TextFieldType;
13 import flash.events.MouseEvent;
14 import flash.events.NetStatusEvent;
15
16 public class TestVidFMS extends Sprite
17 {
18 private var nc:NetConnection;
19 private var ns:NetStream;
20 private var dummy:Object;
21 private var flv_txt:TextField;
22 private var cam:Camera;
23 private var mic:Microphone;
24 private var stateVid:VideoWorks;
25 private var playCheck:Boolean;
26 private var pauseCheck:Boolean;
27 private var playBtn:NetBtn;
28 private var stopBtn:NetBtn;
29 private var pauseBtn:NetBtn;
30 private var recordBtn:NetBtn;

Example 10-26. VideoWorks.as (continued)

Free download pdf