2019-7-3 zhulinan Flash
1. xml文件(album.xml)格式
2. xml的加载及操作 (1) . xml的加载 ... ... var urlRequest:URLRequest = new URLRequest("album.xml"); var urlLoader:URLLoader = new URLLoader(); urlLoader.dataFormat = URLLoaderDataFormat.TEXT; urlLoader.addEventListener(Event.COMPLETE, urlLoaderComplete); urlLoader.load(urlRequest); ... ...
(2). 数据处理 private function urlLoaderComplete(e:Event):void { var album:XML = new XML(e.target.data); var s1:String; var i:uint = 0; for each (var year:XML in album.year) { s1 = year.@id + "届毕业照"; combox.addItem({data: i, label:s1}); //利用ComboBox组件生成历届毕业照目录 i ++; } combox.y = 12; combox.width = 200; combox.height = 34; combox.addEventListener(Event.CHANGE, comboxSelectedHandle); //下拉菜单响应处理 var tft: TextFormat = new TextFormat(); tft.size = 18; tft.font = ft.fontName; //这里ft为从外部加载的字体 combox.textField.setStyle("textFormat", tft); combox.dropdown.setRendererStyle("textFormat" , tft); combox.dropdown.rowHeight = 30; combox.dropdownWidth = 200 ; combox.visible = true; ...... }
(3). 其它 ... ... //获得某一届班级数量 var picCount:uint = album.year[id].pic.length(); //这里id为0(2017届)或1(2018届) ... ... //获得2018届第3个班级的名称,结果为“2018届(3班)” var className:String = album.year[1].@id + "届(" + album.year[1].pic[2].@classId + ")班"; ... ... //获得2018届第1个班级的毕业照地址,结果为“6_2_2018_1.jpg” var url:String = album.year[1].pic[0].@url;