Programmatically removing an Alert using the PopUpManager

The following example shows how you can close an Alert control by calling the PopUpManager class’s removePopUp() method.

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""

            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private var alert:Alert;

            private function showAndHide(delay:Number):void {
                var alertText:String = "I'm an Alert control. I'll disappear in " + (delay / 1000).toFixed(1) + " seconds.";
                var alertTitle:String = "Timed Alert";
                alert =, alertTitle);
                setTimeout(hideAlert, delay);

            private function hideAlert():void {

    <mx:ApplicationControlBar dock="true">
        <mx:Button label="Launch alert"
                click="showAndHide(3000);" />


View source is enabled in the following example.

4 thoughts on “Programmatically removing an Alert using the PopUpManager

  1. Hi dude,
    Thanx a ton for all your posts, specially alert related. It is really very helpful for newbies and lazy people like me :). Very Good job, keep it up

Comments are closed.