as3.0读取xml内视频地址
importflash.utils.Timer;importflash.display.*;importflash.events.*;importflash.net.*;...
import flash.utils.Timer;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.*;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
var myxml:XML;
//var xmllist:XMLList;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("flvurlid.xml");
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
if (loader != null)
{
myxml = new XML(loader.data);
//xmllist = myxml.elements();
trace(myxml.urls[0].fvurl);
}
else
{
trace("loader is not a URLLoader!");// 结果:http://swf.games.sina.com.cn/tgy/zwjvideo/zuiwujinew.flv
}
}
/////////////////////////
var MyNC:NetConnection = new NetConnection();
MyNC.connect(null);
var MyNS:NetStream = new NetStream(MyNC);
MyNS.play(myxml.urls[0].fvurl);//这里始终有问题,输出无法访问空对象引用的属性或方法。
////////////////;
my_video.attachNetStream(MyNS);
////;
var countTimer:Number;
var customClient:Object=new Object();
MyNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function asyncErrorHandler(event:AsyncErrorEvent):void
{
}//ignore metadata error message
MyNS.addEventListener(NetStatusEvent.NET_STATUS,sths);
function sths(e)
{
if (e.info.code == "NetStream.Play.Stop")
{
trace("播放完了");
}
} 展开
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.*;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
var myxml:XML;
//var xmllist:XMLList;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("flvurlid.xml");
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
if (loader != null)
{
myxml = new XML(loader.data);
//xmllist = myxml.elements();
trace(myxml.urls[0].fvurl);
}
else
{
trace("loader is not a URLLoader!");// 结果:http://swf.games.sina.com.cn/tgy/zwjvideo/zuiwujinew.flv
}
}
/////////////////////////
var MyNC:NetConnection = new NetConnection();
MyNC.connect(null);
var MyNS:NetStream = new NetStream(MyNC);
MyNS.play(myxml.urls[0].fvurl);//这里始终有问题,输出无法访问空对象引用的属性或方法。
////////////////;
my_video.attachNetStream(MyNS);
////;
var countTimer:Number;
var customClient:Object=new Object();
MyNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function asyncErrorHandler(event:AsyncErrorEvent):void
{
}//ignore metadata error message
MyNS.addEventListener(NetStatusEvent.NET_STATUS,sths);
function sths(e)
{
if (e.info.code == "NetStream.Play.Stop")
{
trace("播放完了");
}
} 展开
展开全部
var MyNS:NetStream = new NetStream(MyNC); 这一句有逻辑问题。 参考api改正确把
更多追问追答
追问
哪有啊?api也是这样写的呀
api上也是这样写,如果MyNS.play(myxml.urls[0].fvurl)改为MyNS.play("http://swf.games.sina.com.cn/tgy/zwjvideo/zuiwujinew.flv" )这个具体地址就不会有问
这样也不会出问题,关键是读取xml文档的地址放进去为何就不行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询