首页 >php教程 >PHP开发 >flex actionScript读取文件示例代码

flex actionScript读取文件示例代码

高洛峰
高洛峰原创
2016-12-27 17:03:301175浏览

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中文网!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn