假设xml格式 <xml> <pic url="图片地址" linkurl="连接地址"。。。> </pic> </xml> //图片容器 public class PicClass extends Sprite{ private var link_url:String; private var pic_url:String; private var loader:Loader; public function PicClass(){ loader = new Loader(); addChild(loader); }
public function init(xml:XML):void{ this. pic_url = xml.@url; this.link_ulr = xml.@linkurl; loader.load(this.pic_url); } } //主类 public class Main extends Sprite{ public function Main():void{ var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, onLoadedxml); loader.load(new URLRequest("xml地址")); } private function onLoadedxml(evt:Event):void{ var xml:XML = new XML(evt.target.data); for(var i:int = 0;i < xml.pic.length();i ++){ var pic:PicClass = new PicClass(); pic.init(xml.pic[i]);