我想通过as3.0+xml方式加载多张图片,并且为每张图片添加不同的超链接?xml取名picture。xml:谢谢!
2个回答
展开全部
var a:URLLoader = new URLLoader(); a.load(new URLRequest("picture.xml"));
a.addEventListener(Event.COMPLETE,h);
function h(evt:Event):void{
var xml:XML = new XML(a.data);
var n:int = xml.img.length();
for (var i:int = 0; i < n; i++) {
var tupian:Loader = new Loader();
tupian.load(new URLRequest(xml.img[i].@src));
tupian.x = 10 + i*201;
addChild(tupian);
var href:String = xml.img[i].@href;
tupian.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void{
navigateToURL(new URLRequest(href));
}
}
}
a.addEventListener(Event.COMPLETE,h);
function h(evt:Event):void{
var xml:XML = new XML(a.data);
var n:int = xml.img.length();
for (var i:int = 0; i < n; i++) {
var tupian:Loader = new Loader();
tupian.load(new URLRequest(xml.img[i].@src));
tupian.x = 10 + i*201;
addChild(tupian);
var href:String = xml.img[i].@href;
tupian.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void{
navigateToURL(new URLRequest(href));
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询