flex actionScript读取文件示例代码

编程学习 2021-07-05 11:32www.dzhlxh.cn编程入门
本节主要介绍了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); 

    }); 

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板