<?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; modalTransparencyDuration</title>
	<atom:link href="http://blog.flexexamples.com/tag/modaltransparencyduration/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>Globally setting modal styles in a Flex application</title>
		<link>http://blog.flexexamples.com/2007/10/12/globally-setting-modal-styles-in-a-flex-application/</link>
		<comments>http://blog.flexexamples.com/2007/10/12/globally-setting-modal-styles-in-a-flex-application/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 05:28:46 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Alert]]></category>
		<category><![CDATA[PopUpManager]]></category>
		<category><![CDATA[modalTransparency]]></category>
		<category><![CDATA[modalTransparencyBlur]]></category>
		<category><![CDATA[modalTransparencyColor]]></category>
		<category><![CDATA[modalTransparencyDuration]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/12/globally-setting-modal-styles-in-a-flex-application/</guid>
		<description><![CDATA[<p>The topic of setting modal styles came up again today so I thought I&#8217;d re-share this tip (I previously covered controlling modal styles for the Alert control in an earlier post, <a href="http://blog.flexexamples.com/2007/08/14/changing-a-modal-alert-controls-blur-transparency-and-transparency-color/">&#8220;Changing a modal Alert control’s blur, transparency and transparency color&#8221;</a>).</p> <p>The following example shows how you can set the various modal styles (modalTransparencyBlur, [...]]]></description>
			<content:encoded><![CDATA[<p>The topic of setting modal styles came up again today so I thought I&#8217;d re-share this tip (I previously covered controlling modal styles for the Alert control in an earlier post, <a href="http://blog.flexexamples.com/2007/08/14/changing-a-modal-alert-controls-blur-transparency-and-transparency-color/">&#8220;Changing a modal Alert control’s blur, transparency and transparency color&#8221;</a>).</p>
<p>The following example shows how you can set the various modal styles (<code>modalTransparencyBlur</code>, <code>modalTransparency</code>, <code>modalTransparencyColor</code>, and <code>modalTransparencyDuration</code>) on the global selector so it propogates to both the Alert control and pop-ups created using the PopUpManager.</p>
<p>Full code after the jump.</p>
<p><span id="more-233"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Global_modal_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/12/globally-setting-modal-styles-in-a-flex-application/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        global {
            modalTransparencyBlur: 0;
            modalTransparency: 0.8;
            modalTransparencyColor: black;
            modalTransparencyDuration: 500;
        }
    &lt;/mx:Style&gt;

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

            private function showAlert():void {
                Alert.show("hello", "world");
            }

            private function showContactForm():void {
                var contactForm:ContactForm = new ContactForm();
                PopUpManager.addPopUp(contactForm, this, true);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Alert" click="showAlert();" /&gt;
        &lt;mx:Button label="ContactForm" click="showContactForm();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Global_modal_test/ContactForm.mxml">View ContactForm.mxml</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/12/globally-setting-modal-styles-in-a-flex-application/ --&gt;
&lt;mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
        width="320"
        height="240"
        showCloseButton="true"
        close="titleWindow_close();"
        creationComplete="titleWindow_creationComplete();"&gt;

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

            private function titleWindow_close():void {
                PopUpManager.removePopUp(this);
            }

            private function titleWindow_creationComplete():void {
                PopUpManager.centerPopUp(this);
            }

            private function sendButton_click():void {
                Alert.show("Thanks for the feedback");
                titleWindow_close();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Form styleName="plain" width="100%" height="100%"&gt;
        &lt;mx:FormHeading label="Contact Us" /&gt;
        &lt;mx:FormItem label="Name:" width="100%"&gt;
            &lt;mx:TextInput id="feedbackName" width="100%" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="Email:" width="100%"&gt;
            &lt;mx:TextInput id="feedbackEmail" width="100%" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="Comments:" width="100%" height="100%"&gt;
            &lt;mx:TextArea id="feedbackComments" width="100%" height="100%" /&gt;
        &lt;/mx:FormItem&gt;
    &lt;/mx:Form&gt;

    &lt;mx:ControlBar horizontalAlign="right"&gt;
        &lt;mx:Button id="sendButton"
                label="Send"
                click="sendButton_click();" /&gt;
    &lt;/mx:ControlBar&gt;

&lt;/mx:TitleWindow&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Global_modal_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/Global_modal_test/bin/main.html" width="100%" height="400"></iframe></p>
<p class="new">Bruno asks if you can change the modalTransparencyColor and other modalTransparency* styles at runtime. The short answer? &#8220;Yes&#8221;. The following example shows how you can change the modalTransparencyColor style on-the-fly at runtime using the following code: <code>StyleManager.getStyleDeclaration("global").setStyle("modalTransparencyColor", "haloBlue");</code></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/global_modelTransparency_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/12/globally-setting-modal-styles-in-a-flex-application/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        global {
            modalTransparencyBlur: 0;
            modalTransparency: 0.8;
            modalTransparencyColor: black;
            modalTransparencyDuration: 500;
        }
    &lt;/mx:Style&gt;

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

            private function showAlert():void {
                Alert.show("hello", "world");
            }

            private function setModelTransparencyColorStyle(color:Object):void {
                StyleManager.getStyleDeclaration("global").setStyle("modalTransparencyColor", color);
                showAlert();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="red"
                fillColors="[red,red]"
                click="setModelTransparencyColorStyle(0xFF0000);" /&gt;
        &lt;mx:Button label="haloGreen"
                fillColors="[haloGreen,haloGreen]"
                click="setModelTransparencyColorStyle('haloGreen');" /&gt;
        &lt;mx:Button label="haloBlue"
                fillColors="[haloBlue,haloBlue]"
                click="setModelTransparencyColorStyle('haloBlue');" /&gt;
        &lt;mx:Button label="haloSilver"
                fillColors="[haloSilver,haloSilver]"
                click="setModelTransparencyColorStyle('haloSilver');" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/global_modelTransparency_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/global_modelTransparency_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Globally setting modal styles in a Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/12/globally-setting-modal-styles-in-a-flex-application/',contentID: 'post-233',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'modalTransparency,modalTransparencyBlur,modalTransparencyColor,modalTransparencyDuration',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/12/globally-setting-modal-styles-in-a-flex-application/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

