请各位flash高手帮忙逐句翻译如下语句(读取外部文件)

来源:百度知道 编辑:UC知道 时间:2024/06/17 14:25:56
newLoadFile= new LoadVars();
newLoadFile.onData = function(rw) {
if (rw.indexOf("\r\n")>-1) {
trace("读取完毕");
}
inputtext.text = replacePunc(rw);
};

function replacePunc(str) {
var tempArray = str.split("\r\n");
var tempstr = new String();
for (var i = 0; i<tempArray.length; i++) {
tempstr += tempArray[i]+newline;
}
return tempstr;
}

System.useCodepage = true;
newLoadFile.load("aa.txt");
此段语句主要是放在课件里帮助读取外部的.txt文档用的。麻烦各位高人在把每句语句的注解写的清楚些。谢了!!!

看样你是从来没接触过as,也不知道你怎么应用,解释起来更麻烦!你给的这段代码有的是没必要的.

//声明载入变量
var newLoadFile = new LoadVars();
//载入的文件处理(载入方法给你修改了)
newLoadFile.onLoad = function(rw) {
//你这里是如果实现什么值是大于-1然后执行。。。(你破解的吧)
if (rw.indexOf("\r\n")>-1) {
trace("读取完毕");
//你竟然没放进来执行函数,看样是破解的,不然你这些代码一点用都没有
replacePunc(str);
} else {
trace("没有文件可载入");
}
//这是文本里显示字,应该放在上面的如果语句里吧!!!
inputtext.text = replacePunc(rw);
};
//下面是当载入外部文本成功后。。。
function replacePunc(str) {
//下面是for循环,也不知道你做啥用的,这些变量都是从外部文件里获得吧。
var tempArray = str.split("\r\n");
var tempstr = new String();
for (var i = 0; i<tempArray.length; i++) {
tempstr += tempArray[i]+newline;
}
return tempstr;
}
//防止乱码
System.useCodepage = true;
//载入外部文件地址。
newLoadFile.load("aa.txt");