var vid: Video = new Video();
var ns: NetStream
var nc: NetConnection = new NetConnection();
var customClient:Object = this;
customClient.onMetaData = metaDataHandler;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusF);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorF);
nc.connect(null);
function netStatusF(e:NetStatusEvent):void {
switch (e.info.code) {
case "NetConnection.Connect.Success":
connectF();
break;
case "NetStream.Play.StreamNotFound":
connectF('video2.flv'); // but i would probably loop through an array of possible videos.
break;
}
}
function connectF(videoS:String='video1.flv'):void {
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusF);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.addEventListener(IOErrorEvent.IO_ERROR, ioErrorF);
ns.client = customClient;
ns.play(videoS);
vid.attachNetStream(ns);
addChild(vid);
}