flash通过xml加载视频要怎么做啊~~~~~
1个回答
展开全部
1. xml文件,<root>
<video>
<url>xxx<url>
</video>
</root>
2. Flash中加载xml。
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
public class Weather extends MovieClip {
private var xmlloader:URLLoader;
private var xml:XML;
private var videourl:String;
private var rand:Number = Math.random();
private var urlweather:String = "http://flash.weather.com.cn/xml/upload.xml?rand="+rand";
//private var urlweather:String = "upload.xml";
public function Weather() {
xmlloader = new URLLoader();
xmlloader.load(new URLRequest(urlweather));
xmlloader.addEventListener(Event.COMPLETE,onCompleteXml);
}
private function onCompleteXml(e:Event):void
{
xml = XML(e.target.data);
/ /trace(xml)
var xmllist:XMLList = xml.elements();
var lengths:int = xmllist.length();
videourl = xmllist[0].url; //
}
}
// 视屏代码、
videoSprite = new Sprite();
movieObj = new Object();
netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
customClient= {onMetaData:metaDataHandler};
netStream.client = customClient;
netStream.play(videourl); //此videourl变量xml中的视屏路径地址。
netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
video = new Video(598,336);
video.attachNetStream(netStream);
videoSprite.addChild(video);
this.addChild(videoSprite);
}
关于视屏的各种控制我就不写了。
<video>
<url>xxx<url>
</video>
</root>
2. Flash中加载xml。
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
public class Weather extends MovieClip {
private var xmlloader:URLLoader;
private var xml:XML;
private var videourl:String;
private var rand:Number = Math.random();
private var urlweather:String = "http://flash.weather.com.cn/xml/upload.xml?rand="+rand";
//private var urlweather:String = "upload.xml";
public function Weather() {
xmlloader = new URLLoader();
xmlloader.load(new URLRequest(urlweather));
xmlloader.addEventListener(Event.COMPLETE,onCompleteXml);
}
private function onCompleteXml(e:Event):void
{
xml = XML(e.target.data);
/ /trace(xml)
var xmllist:XMLList = xml.elements();
var lengths:int = xmllist.length();
videourl = xmllist[0].url; //
}
}
// 视屏代码、
videoSprite = new Sprite();
movieObj = new Object();
netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
customClient= {onMetaData:metaDataHandler};
netStream.client = customClient;
netStream.play(videourl); //此videourl变量xml中的视屏路径地址。
netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
video = new Video(598,336);
video.attachNetStream(netStream);
videoSprite.addChild(video);
this.addChild(videoSprite);
}
关于视屏的各种控制我就不写了。
来自:求助得到的回答
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
一诺动画
2024-10-27 广告
2024-10-27 广告
Flash动画制作在北京一之诺文化传媒有限公司是一项创意与技术并重的服务。我们团队精通于利用Flash或兼容技术,将客户的想象转化为生动、流畅的动画作品。从概念设计到分镜脚本,再到精细的绘制与后期特效处理,每一步都力求完美呈现。无论是广告动...
点击进入详情页
本回答由一诺动画提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询