【动态生成方法通过加载xml将数据添加进list】动态生成方法通过加载XML,将数据添加进LIST

更新时间:2015-04-18    来源:代码生成    手机版     字体:

【www.bbyears.com--代码生成】

动态生成方法通过加载XML,将数据添加进LIST

 //解决乱码的问题...
System.useCodepage = true;
//定义doc_xml为XML类;
var doc_xml:XML = new XML();
//忽略空格.
doc_xml.ignoreWhite = true;
doc_xml.onLoad = _root.xmlload;
//初次加载文件为"renming.xml"...
_root.doc_xml.load("renming.xml");
function xmlload() {
var childnodes = this.firstChild.childNodes;
//防止垒加,这句话的含义就是让my_list每次加载的XML不一样。
_root.my_list.removeAll();
for (var i:Number = 0; i   _root.my_list.addItem(childnodes[i].attributes.label, childnodes[i].attributes.data);
}
}
通过按钮点击,分别加载不同的XML文件

//定义地名按钮被激发时,加载地名。。。
diming.onRelease = function() {
_root.doc_xml.load("diming.xml");
};
renming.onRelease = function() {
_root.doc_xml.load("renming.xml");
};
shijian.onRelease = function() {
_root.doc_xml.load("shijian.xml");
};

调用被鼠标点击后的对象,以及调用该对象的数据:

_root.onEnterFrame = function() {
show_txt_label = _root.my_list.selectedItem.label;
show_txt_data = _root.my_list.selectedItem.data;
};

本文来源:http://www.bbyears.com/wangyetexiao/14465.html

猜你感兴趣

热门标签

更多>>

本类排行