2011-02-18 72 views
0

我在我的應用程序中有一個計時器。每隔30分鐘,它將打擊Web服務並獲取數據並更新UI。該應用程序工作正常,直到昨天。突然之間,由於某些問題,網絡服務暫時無法使用。在此期間,應用程序在警報窗口中多次顯示RPC錯誤(超過100個警報框)。由於這個警報箱,我的申請被吊死,我無法做任何事情。如何避免在Flex中顯示多個警報窗口

我嘗試了幾種方法,但沒有奏效。最後,我試圖使用一個標誌。在所有的方法中,這看起來很有希望。所以我已經實現了它。基本上,在這種方法中,每當我們打開警報時,我們將設置一個標誌。當打開和關閉警報時,我們將重置此標誌。但它沒有按預期工作。有什麼方法可以幫助我們避免多個警報窗口。

請幫我解決這個問題。

回答

2

我會寫的包裝打開警報,並且只能使用此包裝,而不是在代碼Alert.show:

public class AlertWrapper { 

    private static var lastAlert:Alert; 

    public static function showAlert(text:String, title:String):void { 
     if (lastAlert) { 
      PopUpManager.removePopUp(lastAlert); 
      //or 
      //return; //ignore last alert 
     } 
     lastAlert = Alert.show(text, title, null, 4, onAlertClose); 
    } 

    private static function onAlertClose(event:CloseEvent):void { 
     lastAlert = null; 
    } 
} 

進口失蹤,但我希望這個想法是清楚的。

+0

給出一些錯誤。我無法在此發佈完整的錯誤。錯誤 \t at mx.managers :: SystemManager/updateLastActiveForm()[C:\ autobuild \ 3.2.0 \ frameworks \ projects \ framework \ src \ mx \ managers \ SystemManager.as:5087] \t at mx.managers :: SystemManager/activateForm()[C:\ autobuild \ 3.2.0 \ frameworks \ projects \ framework \ src \ mx \ managers \ SystemManager.as:2352] \t at mx.managers :: SystemManager/activate()[C:\ mx.managers :: FocusManager/creationCompleteHandler()[C:\ autobuild \ .. \ mx \ managers \ autobuild \ 3.2.0 \ frameworks \ projects \ framework \ src \ mx \ managers \ SystemManager.as:2307] \t FocusManager.as:1592] ...... – Dinesh 2011-02-18 09:11:59

相關問題