I've been trying for days to figure out how to get a video to play in flash and I have got pretty much nowhere. I have the code below but have no idea what else to try to get it to work. Can anyone please help?
var conn:NetConnection = new NetConnection();
conn.connect(null);
var nstream:NetStream = new NetStream(conn);
nstream.setBufferTime(10);
trailer.attach(nstream);
nstream.play("arthur.flv");
Looks like you forgot one crutial part, you need to add the NetStream to a video object after the NetConnection has connected successfully.
var connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + videoURL);
break;
}
}
function connectStream():void {
stream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = new CustomClient();
var video:Video = new Video();
video.attachNetStream(stream);
stream.play(videoURL);
addChild(video);
}
Take a look at the AS3 NetStream docs here. Theres ALOT of info and examples there to get you on your way.