flex actionScript读取文件示例代码

import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLVariables;public class TxtLoader { private var setTxt:Function = null; public function TxtLoader() { }public function loadTxt(fileNam

import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
public class TxtLoader
{
private var setTxt:Function = null;
public function TxtLoader()
{
}
public function loadTxt(fileName:String, setTxt:Function):void {
this.setTxt = setTxt;
var urlRequest:URLRequest = new URLRequest(fileName);
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, complete);
urlLoader.load(urlRequest);
}
private function complete(event:Event):void {
var urlLoader:URLLoader = event.currentTarget as URLLoader;
setTxt.call(null, urlLoader.data);
}
}

—————–调用的方法————————————————————-
new TxtLoader().loadTxt(‘readme.txt’, function(txt:String):void {
Alert.show( txt);
});

关于作者: dawei

【声明】:石家庄站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐