欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

flex actionScript读取文件示例代码

程序员文章站 2022-05-06 08:14:04
...
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); 
 
    });

更多flex actionScript读取文件示例代码相关文章请关注PHP中文网!