flex actionScript读取文件示例代码
程序员文章站
2022-06-28 14:07:12
import flash.events.event;
import flash.net.urlloader;
import flash.net.urlre...
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); });
上一篇: 记一次曲折的php入侵