這裡使用了 NetConnection 及 NetStream 配合 Video 組件進行操作, 可以將 FLV 檔案進行播放, 很方便的使用方式, 程式碼如下:
代碼: 選擇全部
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("video.mp4");
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);