This should be possible using the Alert as well, just use the PopUpManager to 
remove the Alert control.

Short answer: PopUpManager.removePopUp(<Alert_instance>);


Long answer:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application name=""
                xmlns:mx="http://www.adobe.com/2006/mxml";
                backgroundColor="white"
                initialize="init();">

        <mx:Script>
                <![CDATA[
                        import mx.controls.Alert;
                        import mx.events.CloseEvent;
                        import mx.managers.PopUpManager;

                        private var alrt:Alert;
                        private var alrtTimer:Timer;

                        private function init():void {
                                alrtTimer = new Timer(5000, 1);
                                
alrtTimer.addEventListener(TimerEvent.TIMER_COMPLETE, removeAlert);
                        }

                        private function showAlert():void {
                                alrt = Alert.show("I'm an Alert control and I 
will close in 5 seconds unless closed by a user.", "Self closing Alert", 
Alert.OK, this, alrt_close);
                                alrtTimer.reset();
                                alrtTimer.start();
                        }

                        private function alrt_close(evt:CloseEvent):void {
                                alrtTimer.stop();
                                trace("Closed by user.");
                        }

                        private function removeAlert(evt:TimerEvent):void {
                                PopUpManager.removePopUp(alrt);
                                trace("Removed by application.");
                        }
                ]]>
        </mx:Script>

        <mx:Button label="Show Alert" click="showAlert();" />

</mx:Application>






From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of lehaianh1986
Sent: Wednesday, April 08, 2009 7:38 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Alert Control help




Thank Carlos

I use Title window and have result I expect. Here is my code

private var tw:TitleWindow = new TitleWindow(); 
private function Load():void
{
tw.title = "Wait to update...";
mx.managers.PopUpManager.addPopUp(tw,this,true);
PopUpManager.centerPopUp(tw);
...
}
// then call remove when finish work
private function handleWorkDone(event:ResultEvent):void
{
PopUpManager.removePopUp(tw);
...
}

--- In flexcoders@yahoogroups.com, "carloscarvalhar" <carloscarval...@...> 
wrote:
>
> i think you need more Popup than Alert...
> 
> you can add childs to your popup, take a look at this example:
> http://blog.flexexamples.com/2007/08/06/creating-custom-pop-up-windows-with-the-popupmanager-class/
> 
> reference:
> http://livedocs.adobe.com/flex/3/langref/mx/managers/PopUpManager.html
> 
> bye
> Carlos
>

Reply via email to