IT码农库

您当前所在位置:首页 > 网络编程 > Flex

Flex

flex actionScript读取文件示例代码

[db:来源] 2014-07-24Flex5749
本节主要介绍了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); 

    }); 
大图广告(830*140)