<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; setTimeout()</title>
	<atom:link href="http://blog.flexexamples.com/tag/settimeout/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Disabling an Alert control in Flex</title>
		<link>http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 06:56:47 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Alert]]></category>
		<category><![CDATA[enabled]]></category>
		<category><![CDATA[setTimeout()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can disable an Alert control for a specified number of milliseconds before the user can dismiss the dialog by setting the enabled property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_enabled_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/ --&#62; &#60;mx:Application name=&#34;Alert_enabled_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34;&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can disable an Alert control for a specified number of milliseconds before the user can dismiss the dialog by setting the <code>enabled</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-834"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_enabled_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/ --&gt;
&lt;mx:Application name=&quot;Alert_enabled_test&quot;
        xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private const ENABLE_DELAY:uint = 3000; // 3 seconds

            private var a:Alert;

            private function showAlert():void {
                a = Alert.show(&quot;You have been logged out.&quot;, &quot;Goodbye&quot;);
                a.enabled = false;
                setTimeout(enableAlert, ENABLE_DELAY, a);
            }

            private function enableAlert(target:Alert):void {
                target.enabled = true;
                // PopUpManager.removePopUp(target);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id=&quot;button&quot;
            label=&quot;Logout&quot;
            click=&quot;showAlert();&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_enabled_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Alert_enabled_test/bin/main.html" width="100%" height="200"></iframe></p>
<p class="new">Update (10/18/2007): If you don&#8217;t want to disable the entire Alert control, you can loop over the internal button array and disable each of the button controls individually, as seen in the following example:</p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/ --&gt;
&lt;mx:Application name=&quot;Alert_enabled_test&quot;
        xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.FlexEvent;
            import mx.utils.ObjectUtil;
            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private const ENABLE_DELAY:uint = 3000; // 3 seconds

            private var a:Alert;

            private function showAlert():void {
                a = Alert.show(&quot;You have been logged out.&quot;, &quot;Goodbye&quot;);
                toggleButtons(a, false);
                setTimeout(enableAlert, ENABLE_DELAY, a);
            }

            private function enableAlert(target:Alert):void {
                toggleButtons(target, true);
            }

            private function toggleButtons(target:Alert, isEnabled:Boolean):void {
                var buttonArr:Array = target.mx_internal::alertForm.mx_internal::buttons;
                var btn:Button;
                for each (btn in buttonArr) {
                    btn.enabled = isEnabled;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id=&quot;button&quot;
            label=&quot;Logout&quot;
            click=&quot;showAlert();&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="alert">Since this example uses the <strong>mx_internal</strong> namespace, you can&#8217;t always depend on this behavior to work in future versions of the Flex SDK. Use at your own risk.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Disabling an Alert control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/',contentID: 'post-834',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'enabled,setTimeout()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/10/17/disabling-an-alert-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Creating timers using the setTimeout method</title>
		<link>http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/</link>
		<comments>http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 04:11:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[clearTimeout()]]></category>
		<category><![CDATA[setTimeout()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/02/14/creating-timers-using-the-setinterval-method/">&#8220;Creating timers using the setInterval() method&#8221;</a>, we saw how you can create a repeating timer using the setInterval() method.</p> <p>In the following example, you will see how to create and cancel non-repeating timers using the setTimeout() and clearTimeout() methods. You&#8217;ll also see how you can pass additional parameters to the [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/02/14/creating-timers-using-the-setinterval-method/">&#8220;Creating timers using the setInterval() method&#8221;</a>, we saw how you can create a repeating timer using the <code>setInterval()</code> method.</p>
<p>In the following example, you will see how to create and cancel non-repeating timers using the <code>setTimeout()</code> and <code>clearTimeout()</code> methods. You&#8217;ll also see how you can pass additional parameters to the <code>setTimeout()</code> method which will get passed along to your custom function.</p>
<p class="note">As pointed out by a keen reader in the previous example, the <code>setInterval()</code> and <code>setTimeout()</code> methods are the non-preferred methods of timers. The new and improved method is to use the Timer class.</p>
<p>Full code after the jump.</p>
<p><span id="more-521"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function delayedAlert():void {
                setTimeout(launchAlert, 2000);
                button.enabled = false;
            }

            private function launchAlert():void {
                alert = Alert.show("I'm an alert.");
                button.enabled = true;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id="button"
            label="Click here to launch alert (2 second delay)"
            click="delayedAlert();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>In the following example, we see how to use the <code>clearTimeout()</code> method to cancel the timer. Note how this time we save the uint value returned from the <code>setTimeout()</code> method. This saved value will be later passed to the <code>clearTimeout()</code> method.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_2/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import flash.utils.clearTimeout;
            import mx.controls.Alert;

            private var alert:Alert;
            <strong style="color:red;">private var timeoutID:uint;</strong>

            private function delayedAlert():void {
                <strong style="color:red;">timeoutID = </strong>setTimeout(launchAlert, 2000);
                startBtn.enabled = false;
                cancelBtn.enabled = true;
            }

            private function launchAlert():void {
                alert = Alert.show(&quot;I'm an alert.&quot;);
                startBtn.enabled = true;
                cancelBtn.enabled = false;
            }

            private function cancelAlert():void {
                <strong style="color:red;">clearTimeout(timeoutID);</strong>
                startBtn.enabled = true;
                cancelBtn.enabled = false;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id=&quot;startBtn&quot;
            label=&quot;Click here to launch alert (2 second delay)&quot;
            click=&quot;delayedAlert();&quot; /&gt;

    &lt;mx:Button id=&quot;cancelBtn&quot;
            label=&quot;Cancel alert!&quot;
            enabled=&quot;false&quot;
            emphasized=&quot;true&quot;
            color=&quot;red&quot;
            themeColor=&quot;red&quot;
            click=&quot;cancelAlert();&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_2/bin/main.html" width="100%" height="200"></iframe></p>
<p>The following example shows you how you can pass additional parameters to the <code>setTimeout()</code> method, and how those parameters are then passed to your custom function, which in this case is the <code>launchAlert()</code> method. Note how the <code>launchAlert()</code> method takes two parameters: <code>message</code> (required) and <code>title</code> (optional; default empty string).</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_3/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function delayedAlert():void {
                setTimeout(launchAlert, 2000<strong style="color:red;">, &quot;Alert message&quot;, &quot;Alert title&quot;</strong>);
                button.enabled = false;
            }

            private function launchAlert(<strong style="color:red;">message:String, title:String = &quot;&quot;</strong>):void {
                alert = Alert.show(<strong style="color:red;">message, title</strong>);
                button.enabled = true;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id=&quot;button&quot;
            label=&quot;Click here to launch alert (2 second delay)&quot;
            click=&quot;delayedAlert();&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_3/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/setTimeout_test_3/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating timers using the setTimeout method on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/',contentID: 'post-521',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'clearTimeout(),setTimeout()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Displaying a TextInput control&#8217;s text as a password in Flex (redux)</title>
		<link>http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/</link>
		<comments>http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 16:42:45 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[PopUpManager]]></category>
		<category><![CDATA[TextInput]]></category>
		<category><![CDATA[displayAsPassword]]></category>
		<category><![CDATA[focusIn]]></category>
		<category><![CDATA[focusOut]]></category>
		<category><![CDATA[removePopUp()]]></category>
		<category><![CDATA[setTimeout()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/</guid>
		<description><![CDATA[<p>We&#8217;ve already seen how to get a TextInput control to display its text as a masked password field before in an earlier example, <a href="http://blog.flexexamples.com/2008/01/05/displaying-a-textinput-controls-text-as-a-password-in-flex/">&#8220;Displaying a TextInput control&#8217;s text as a password in Flex&#8221;</a> by setting the displayAsPassword property to true.<br /> The following example will show you how you can listen for the focusIn [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve already seen how to get a TextInput control to display its text as a masked password field before in an earlier example, <a href="http://blog.flexexamples.com/2008/01/05/displaying-a-textinput-controls-text-as-a-password-in-flex/">&#8220;Displaying a TextInput control&#8217;s text as a password in Flex&#8221;</a> by setting the <code>displayAsPassword</code> property to <code>true</code>.<br />
The following example will show you how you can listen for the <code>focusIn</code> and <code>focusOut</code> events to toggle the <code>displayAsPassword</code> property so that when the password field has focus the text is displayed as plain text, and when the password field does not have focus the text is displayed as masked text.</p>
<p>Full code after the jump.</p>
<p><span id="more-484"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TextInput_displayAsText_test_2/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private var alert:Alert;

            private function submit_click():void {
                alert = Alert.show("Closing in 3 seconds.",
                                    "Submitting...");
                setTimeout(closeAlert, 3000);
            }

            private function reset_click():void {
                alert = Alert.show("Closing in 1 second.",
                                    "Resetting...");
                username.text = "";
                password.text = "";
                setTimeout(closeAlert, 1000);
            }

            private function closeAlert():void {
                PopUpManager.removePopUp(alert);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Panel title="Login"&gt;
        &lt;mx:Form&gt;
            &lt;mx:FormItem label="Username:" required="true"&gt;
                &lt;mx:TextInput id="username"
                        text="JohnDoe"
                        maxChars="16" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="Password:" required="true"&gt;
                &lt;mx:TextInput id="password"
                        text="p455w0rd"
                        maxChars="16"
                        displayAsPassword="true"
                        focusIn="password.displayAsPassword = false;"
                        focusOut="password.displayAsPassword = true;" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
        &lt;mx:ControlBar horizontalAlign="right"&gt;
            &lt;mx:Button id="submit"
                    label="Submit"
                    click="submit_click();" /&gt;
            &lt;mx:Button id="reset"
                    label="Reset"
                    click="reset_click();" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/TextInput_displayAsText_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/TextInput_displayAsText_test_2/bin/main.html" width="100%" height="220"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Displaying a TextInput control\&#039;s text as a password in Flex (redux) on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/',contentID: 'post-484',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'displayAsPassword,focusIn,focusOut,removePopUp(),setTimeout()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/27/displaying-a-textinput-controls-text-as-a-password-in-flex-redux/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Programmatically removing an Alert using the PopUpManager</title>
		<link>http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/</link>
		<comments>http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 02:49:34 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Alert]]></category>
		<category><![CDATA[PopUpManager]]></category>
		<category><![CDATA[removePopUp()]]></category>
		<category><![CDATA[setTimeout()]]></category>
		<category><![CDATA[show()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/</guid>
		<description><![CDATA[<p>The following example shows how you can close an Alert control by calling the PopUpManager class&#8217;s removePopUp() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_removePopUp_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; import mx.managers.PopUpManager; private var alert:Alert; private function showAndHide(delay:Number):void { var alertText:String = [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can close an Alert control by calling the PopUpManager class&#8217;s <code>removePopUp()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-247"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_removePopUp_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            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 = Alert.show(alertText, alertTitle);
                setTimeout(hideAlert, delay);
            }

            private function hideAlert():void {
                PopUpManager.removePopUp(alert);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Launch alert"
                click="showAndHide(3000);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_removePopUp_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_removePopUp_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Programmatically removing an Alert using the PopUpManager on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/',contentID: 'post-247',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'removePopUp(),setTimeout(),show()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/10/22/programmatically-removing-an-alert-using-the-popupmanager/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

