外部文本文件格式必须为:
a1=c1&a2=c2&a3=c3,多变量用&连接
在Flash中
System.useCodepage = true;处理编码问题
var Confload = new LoadVars ();
Confload.onLoad = function (success) {
if (success) { trace ("载入成功!"); trace (Confload.a1); trace (Confload.a2); trace (Confload.a3);
} else { trace ("载入失败!");
}
};
Confload.load ("Example.txt");
读取xml文件
var xmlLoad = new XML ();
// 忽略空格
xmlLoad.ignoreWhite = true;
xmlLoad.onLoad = function (success) {
if (success) {
trace(xmlLoad.childNodes[0].childNodes[0].childNodes[0].attributes.ipmode);
trace(xmlLoad.childNodes[0].childNodes[0].childNodes[0].attributes.mac);
} else {
}
};
xmlLoad.load("Config_Example.xml");
System.useCodepage=true;
var mytext,mytxt,img;
loadVariablesNum("test.txt",0);
loadMovie(img,mymc);
var LV=new LoadVars();
LV.onLoad=function(ok)
{
if(ok)
{ mytext=this.mytext;
mytxt=this.mytxt;
loadMovie(this.img,mymc); }
}
LV.load("test.txt")System.useCodepage = true;
/////////////加载TXT文本
var txt_lv:LoadVars = new LoadVars();
txt_lv.onData = function(str:String) {
txt_txt.text = str;
};
txt_lv.load("test.txt");
///////////加载XML文本
var txt_xml:XML = new XML();
txt_xml.ignoreWhite = true;
txt_xml.onLoad = function() {
xml_txt.text = this.firstChild.childNodes;
};
txt_xml.load("test.xml"); |