actionScript读取文件 flex actionScript读取文件代码实例
人气:0想了解flex actionScript读取文件代码实例的相关内容吗,在本文为您仔细讲解actionScript读取文件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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(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); });
加载全部内容