Question

I need to programmatically remove an alert.

This is why: My application uses BrowserManager to enable deep linking based off of the content in the #hash part of the url. If an alert is currently up, and the user hits the back button, the application will revert back to its previous state. But the Alert will still be up, and in many cases irrelevant at that point.

So is there a way to programmatically remove the Alert? so when the hash fragment changes I can remove it.

Thanks!

Was it helpful?

Solution

It turns out the Alert.show function returns an Alert reference and then just uses PopUpManager to add it to the display list. so if you capture the return reference when you call Alert.show you can tell PopUpManager to remove it. :)

OTHER TIPS

You can do this by keeping the Alert object as member data, and then setting its visible property to false when you're done with it. Next time you need to show an Alert, don't create a new one - grab the one you've already created and set its properties, then set visible to true again.

private var myAlert : Alert;

public void showAlert( message: String, title : String ) : void
{
    hideAlert();

    myAlert = Alert.show( message, title, Alert.OK | Alert.NONMODAL );
}

public void hideAlert() : void
{
    if( myAlert != null && myAlert.visible ) {
        myAlert.visible = false;
    }
}

I don't think that is possible.

You can create your own alert component subclassing TitleWindow and then use PopupManager to show/hide them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top