首頁 >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