A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Timer date help!

Threaded View

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    resolved [RESOLVED] Timer date help!

    Hi,

    I'm having problems with the NetStream object in terms of ending a video---I am being told that the _stream.time object is null.

    Code:
    	private var vidConnectionCommercial:NetConnection;
    		private var videoCommercial:Video;
    		private var stCommercial:SoundTransform;
    		private var customClientCommercial:Object = new Object();
    		private var _duration:uint;
    		var _stream:NetStream;	
    
    public function vidDisplayCommercial() {
    			trace("video call");
    			var videoCommercial=new Video(760,477);
    			_duration=0;
    			var vidConnectionCommercial=new NetConnection();
    			vidConnectionCommercial.connect(null);
    			var _stream:NetStream=new NetStream(vidConnectionCommercial);
    			_stream.play("eas.f4v");
    			var customClientCommercial:Object=new Object();
    			customClientCommercial.onMetaData=metaDataHandler;
    			_stream.client=customClientCommercial;
    			_stream.bufferTime=5;
    			_stream.addEventListener(NetStatusEvent.NET_STATUS, onStatusCommercial,false,0, true);
    			videoCommercial.attachNetStream(_stream);
    			commercials.addChild(videoCommercial);
    			commercials.soundTransform=new SoundTransform(1);
    			var stCommercial:SoundTransform=new SoundTransform();
    			stCommercial.volume=1;
    			_stream.soundTransform=stCommercial;
    			addEventListener(Event.ENTER_FRAME, onEnterFrames,false,0,true);
    			_stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandlerCommercial,false,0, true);
    
    			function asyncErrorHandlerCommercial(evt:AsyncErrorEvent):void {
    				//ignore error
    			}
    		}
    		public function onStatusCommercial(e:Object):void {
    			trace(e.info.code);
    			if (e.info.code == "NetStream.Play.Start" &&
    			   e.info.code == "NetStream.Buffer.Full") {
    				trace("loaded");
    			} else if (e.info.code == "NetStream.Buffer.Empty") {
    				trace("empty");
    				}
    			if (e.info.code=="NetStream.Play.Stop") {
    				trace("stopped");
    				}
    	}
    		private function metaDataHandler(data:Object):void {
    			_duration=data.duration;
    			trace(_duration, "duration metaHandler");
    	}
    		private function onEnterFrames(event:Event):void {
    			if (_duration>0) {
    				trace(_duration, "onFrames duration");
    				if (_stream.time>=_duration) {
    					trace("COMPLETE");
    					videoCommercial.clear();
    					commercials.removeChild(videoCommercial);
    
    				}
    			}
    		}
    Could someone tell me how to determine the current NetStream time?

    Thanks,
    ---Yvette
    Last edited by yvillicana; 10-15-2009 at 04:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center