看板 Flash 關於我們 聯絡資訊
想問一下如何在as3及時讀檔? 小弟我在as3需要先讀入一個config檔後來判斷須要開多少tag 可是尷尬的是我沒法及時讀到檔 在constructor中我呼叫黃色那函式幫我送出要檔的需求 我用debug mode下也看到紅色函式有正確處理 但是監聽事件卻沒法及時收到事件 馬上就執行綠色那段~ 造成我沒法完成我要做的事~ 有沒有那位能告知這樣要如何解決? 感謝~ 程式如下: public class Navigator extends UIComponent { //provide tag label [Bindable] private var dataProvider:ArrayCollection; [Bindable] public var config:String; private var tabbar:TabBar; private var contain:ViewStack; public function Navigator() { config="Tab.txt"; read_config(config); init(); } private function read_config(filename:String):void { var textLoader:URLLoader = new URLLoader(); textLoader.addEventListener(Event.COMPLETE, textLoaded); textLoader.load(new URLRequest(filename)); } private function textLoaded(e:Event):void { //字串處理 this.dataProvider = e.target.data.split('\n'); trace("here "+this.dataProvider.toString()); } ......... ........ ....... ...... ..... .... } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.138.155.180
pm2001:init()應該在textLoaded()裡面 04/20 17:20
fatcats:讀檔案需要時間!! 04/20 17:22
windincloud:感謝以上兩位~ 我搞定了~ 原來這樣簡單~ :p 04/20 18:05