2011-06-13 50 views
1

我有一個Flex應用程序從數據庫加載一些數據。在此期間,我希望我的自定義預加載器保持可見狀態。Flex預加載器必須可見,直到加載其他外部文件

困境是:當我在FlexEvent.INIT_COMPLETE處理程序中推遲dispatchEvent(new Event(Event.COMPLETE))時,加載將永遠不會發生,因爲未輸入下一幀。

我怎樣才能保持加載器運行,直到所有的數據完全加載?

回答

0

預加載器基本上是一個精靈。所有的flex組件都可以擴展精靈,所以你可以很容易地繼續使用精靈。我不確定覆蓋應用程序框架的部分是多麼困難,它刪除了預加載器精靈..但是,我認爲您可以使用自定義組件將精靈添加回舞臺。

您可能必須創建一個UIComponent並添加預加載器組件,以便可以將它與狀態一起使用。然後將您的NEW UIComponent設置爲默認狀態。

以下是我的頭頂上的「僞代碼」。

public class MyFlexPreLoader extends UIComponent{ 

    private var var preloader:YourBasePreLoader; //This is the preloader you're already using 

    override protected function createChildren(){ 
      //Add the Preloader here! 
      preloader = new YourBasePreLoader(); 
      addChild(preloader); 
    } 
    //Also add event listeners to manipulate your preloader to show the progress of loading stuff from DB 
} 

然後在你的應用程序

<comp:MyFlexPreLoader includeIn="preloading"/> 

現在,當你完成從預加載改變應用程序將currentState了。您可能需要重寫UIComponent中的更多方法才能使其正常工作。