import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
private var myNc:NetConnection;
private var client:Object;
private var videoStream:NetStream;
private var video:Video;
private var videoURL:String;
myNc = new NetConnection();
myNc.connect(null);
client = new Object();
videoStream =new NetStream(myNc);
video = new Video();
video.width = 350;
video.height = 200;
video.x = 665;
video.y = 190;
sprite.addChild(video);
video.attachNetStream(videoStream);
videoStream.play(videoURL);
videoStream.client=client;
videoStream.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
private function netStatusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success" :
connectStream();
break;
case "NetStream.Play.StreamNotFound" :
trace("Unable to locate video: " + videoURL);
break;
case "NetStream.Buffer.Full" :
break;
case "NetStream.Play.Stop" :
connectStream();
break;
}
}
private function connectStream():void
{
videoStream.pause();
videoStream.seek(0);
videoStream.resume();
}