ActionScript 3.0 Design Patterns

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

187 {

188 pauseCheck=false;
189 if (playCheck)
190 {
191 stopBtn.visible=false;
192 }
193 stateVid.doPause (ns);
194 }
195 else
196 {
197 pauseCheck=true;
198 stopBtn.visible=true;
199 stateVid.doPause (ns);
200
201 }
202 }
203 function doStop (e:MouseEvent):void
204 {
205 playCheck=false;
206 stateVid.stopAll (ns);
207 vid.clear ( );
208 setLocal ( );
209 }
210 //Check connection, instantiate stream,
211 //and set up metadata event handler
212 function checkHookupStatus (event:NetStatusEvent):void
213 {
214 if (event.info.code == "NetConnection.Connect.Success")
215 {
216 ns = new NetStream(nc);
217 dummy=new Object( );
218 ns.client=dummy;
219 dummy.onMetaData=getMeta;
220 ns.addEventListener (NetStatusEvent.NET_STATUS,flvCheck);
221 }
222 }
223 //MetaData
224 function getMeta (mdata:Object):void
225 {
226 trace (mdata.duration);
227 }
228 //Handle flv
229 private function flvCheck (event:NetStatusEvent):void
230 {
231 switch (event.info.code)
232 {
233 case "NetStream.Play.Stop" :
234 stateVid.stopAll(ns);
235 setLocal( );
236 break;
237 case "NetStream.Play.StreamNotFound" :
238 stateVid.stopAll(ns);

Example 10-27. TestFMS.as (continued)

Free download pdf