<?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; StageDisplayState</title>
	<atom:link href="http://blog.flexexamples.com/category/stagedisplaystate/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>Creating full-screen Flex applications in Flex 4 (SWFObject Edition)</title>
		<link>http://blog.flexexamples.com/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/</link>
		<comments>http://blog.flexexamples.com/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 05:11:23 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[FullScreen]]></category>
		<category><![CDATA[StageDisplayState]]></category>
		<category><![CDATA[SWFObject]]></category>
		<category><![CDATA[displayState]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/">&#8220;Creating full-screen Flex applications&#8221;</a>, we saw how to toggle full screen mode in a Flex application by setting the allowFullScreen parameter in the HTML wrapper template&#8217;s AC_FL_RunContent() method.</p> <p>The following example shows how you can enable full screen from your HTML template to your Flex applications using the Flex 4 [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/">&#8220;Creating full-screen Flex applications&#8221;</a>, we saw how to toggle full screen mode in a Flex application by setting the <code>allowFullScreen</code> parameter in the HTML wrapper template&#8217;s <code>AC_FL_RunContent()</code> method.</p>
<p>The following example shows how you can enable full screen from your HTML template to your Flex applications using the Flex 4 SDK (which uses SWFObject now).</p>
<p><span id="more-1004"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Gumbo_FullScreen_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span></span>
<span style="color: #000000;">        applicationComplete=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">            private var fullScreenState:String;</span>
&nbsp;
<span style="color: #000000;">            private function init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                fullScreenState = stage.displayState;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function btn_click<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>btn.selected<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    fullScreenState = StageDisplayState.FULL_SCREEN;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span> else <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    fullScreenState = StageDisplayState.NORMAL;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">                try <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    stage.displayState = fullScreenState;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span> catch <span style="color: #66cc66;">&#40;</span>any:*<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    // ignore</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;20&quot;</span> width=<span style="color: #ff0000;">&quot;150&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span> text=<span style="color: #ff0000;">&quot;width={width}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span> text=<span style="color: #ff0000;">&quot;height={height}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span> text=<span style="color: #ff0000;">&quot;displayState={fullScreenState}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ToggleButton</span> id=<span style="color: #ff0000;">&quot;btn&quot;</span></span>
<span style="color: #000000;">                label=<span style="color: #ff0000;">&quot;Toggle fullscreen&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;btn_click(event);&quot;</span></span>
<span style="color: #000000;">                width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="note"><em><strong>NOTE:</strong> It appears that the /html-template/index.template.html sets the <code>allowfullscreen</code> flag to &#8220;true&#8221; by default now, so you no longer need to manually edit the .HTML templates.</em></p>
<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/spark/Spark_FullScreen_test/bin/srcview/">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/spark/Spark_FullScreen_test/bin/main.html" width="100%" height="150"></iframe></p>
<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating full-screen Flex applications in Flex 4 (SWFObject Edition) on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/',contentID: 'post-1004',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'displayState',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/2009/03/15/creating-full-screen-flex-applications-in-flex-gumbo-swfobject-edition/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Creating full-screen Flex applications</title>
		<link>http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/</link>
		<comments>http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 07:24:27 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[FullScreen]]></category>
		<category><![CDATA[FullScreenEvent]]></category>
		<category><![CDATA[StageDisplayState]]></category>
		<category><![CDATA[displayState]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/</guid>
		<description><![CDATA[<p>Here is a quick post on using Flash Player 9&#8242;s Full-Screen Mode in Flex. I&#8217;ve seen this appear a few times in the bugbase and on lists, but here is some simple code to let you toggle between &#8220;full screen mode&#8221; and &#8220;normal mode&#8221; in a Flex application. Note that in this example I&#8217;m listening [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick post on using Flash Player 9&#8242;s Full-Screen Mode in Flex. I&#8217;ve seen this appear a few times in the bugbase and on lists, but here is some simple code to let you toggle between &#8220;full screen mode&#8221; and &#8220;normal mode&#8221; in a Flex application. Note that in this example I&#8217;m listening for the <code>applicationComplete</code> event in the main &lt;mx:Application /&gt; tag instead of the <code>creationComplete</code> event. The <code>applicationComplete</code> tag is called slightly after the <code>creationComplete</code> event, after the Application has been completely initialized.</p>
<p>If you try and access the <code>Application.application.stage</code> property from the <code>creationComplete</code> event, you&#8217;ll get a run-time error (RTE) saying the following:</p>
<blockquote><p>
TypeError: Error #1009: Cannot access a property or method of a null object reference.<br />
	at main/init()<br />
	at main/___main_Application1_creationComplete()<br />
	at flash.events::EventDispatcher/dispatchEventFunction()<br />
	at flash.events::EventDispatcher/dispatchEvent()<br />
	at mx.core::UIComponent/dispatchEvent()<br />
	at mx.core::UIComponent/set initialized()<br />
	at mx.managers::LayoutManager/doPhasedInstantiation()<br />
	at Function/http://adobe.com/AS3/2006/builtin::apply()<br />
	at mx.core::UIComponent/callLaterDispatcher2()<br />
	at mx.core::UIComponent/callLaterDispatcher()
</p></blockquote>
<p>The example below is pretty bare with just a few Label controls and a Button control, but it should have enough of the required code to give you a push in the right direction.</p>
<p><span id="more-67"></span></p>
<p class="alert">You must have version 9,0,28,0 or greater of Flash Player installed to use full-screen mode. <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Download the latest version of Adobe Flash Player</a>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/FullScreen_test/main.mxml">View MXML</a></p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/ --&gt;
&lt;mx:Application name="FullScreen_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        applicationComplete="init(event)"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import flash.display.StageDisplayState;

            private function init(evt:Event):void {
                /* Set up full screen handler. */
                Application.application.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
                dispState = Application.application.stage.displayState;
            }

            private function fullScreenHandler(evt:FullScreenEvent):void {
                dispState = Application.application.stage.displayState + " (fullScreen=" + evt.fullScreen.toString() + ")";
                if (evt.fullScreen) {
                    /* Do something specific here if we switched to full screen mode. */
                } else {
                    /* Do something specific here if we switched to normal mode. */
                }
            }

            private function toggleFullScreen():void {
                try {
                    switch (Application.application.stage.displayState) {
                        case StageDisplayState.FULL_SCREEN:
                            /* If already in full screen mode, switch to normal mode. */
                            Application.application.stage.displayState = StageDisplayState.NORMAL;
                            break;
                        default:
                            /* If not in full screen mode, switch to full screen mode. */
                            Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
                            break;
                    }
                } catch (err:SecurityError) {
                    // ignore
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:String id="dispState" /&gt;

    &lt;mx:Label text="width={Application.application.width}" /&gt;
    &lt;mx:Label text="height={Application.application.height}" /&gt;
    &lt;mx:Label text="displayState={dispState}" /&gt;

    &lt;mx:Button label="Toggle fullscreen" click="toggleFullScreen()" /&gt;

&lt;/mx:Application&gt;
</pre>
<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/FullScreen_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/FullScreen_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>For more information on Full Screen Mode in Flash Player 9 (ActionScript 2.0 and ActionScript 3.0) check out the following article on the Adobe Developer Center: <a href="http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html">&#8220;Exploring full-screen mode in Flash Player 9&#8243;</a>.</p>
<p class="new">I *knew* I would have forgotten something. The real trick to using FullScreen support is to enable it in the JavaScript embed code, or &lt;object /&gt; and &lt;embed /&gt; tags&#8230; So, in your HTML wrapper, add the following property:</p>
<pre class="code" language="javascript">
AC_FL_RunContent(
    "src", "main",
    "width", "100%",
    "height", "100%",
    "align", "middle",
    "id", "main",
    "quality", "high",
    "bgcolor", "#869ca7",
    "name", "main",
    "allowScriptAccess","sameDomain",
    "type", "application/x-shockwave-flash",
    "pluginspage", "http://www.adobe.com/go/getflashplayer",
    <b style="color:red;">&quot;allowFullScreen&quot;, &quot;true&quot;</b>
);
</pre>
<p>Or, if you are using &lt;object /&gt; and &lt;embed /&gt; tags, you can use the following syntax instead:</p>
<pre class="code" language="html">
&lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;
        id=&quot;main&quot; width=&quot;100%&quot; height=&quot;100%&quot;
        codebase=&quot;http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab&quot;&gt;
        &lt;param name=&quot;movie&quot; value=&quot;main.swf&quot; /&gt;
        &lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;
        &lt;param name=&quot;bgcolor&quot; value=&quot;#869ca7&quot; /&gt;
        &lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;
        <b style="color:red;">&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;</b> /&gt;

    &lt;embed src=&quot;main.swf&quot; quality=&quot;high&quot; bgcolor=&quot;#869ca7&quot;
        width=&quot;100%&quot; height=&quot;100%&quot; name=&quot;main&quot; align=&quot;middle&quot;
        play=&quot;true&quot;
        loop=&quot;false&quot;
        quality=&quot;high&quot;
        allowScriptAccess=&quot;sameDomain&quot;
        <b style="color:red;">allowFullScreen=&quot;true&quot;</b>
        type=&quot;application/x-shockwave-flash&quot;
        pluginspage=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
    &lt;/embed&gt;

&lt;/object&gt;
</pre>
<p class="new">Also, I just learnt from my co-worker Raghu&#8217;s blog (<a href="http://raghunathraoflexing.blogspot.com/">&#8220;FLEXing My Muscle&#8221;</a> and his <a href="http://raghunathraoflexing.blogspot.com/2007/03/error-on-adding-fullscreenlistener-in.html">&#8220;Error on adding FullScreenListener in creationComplete handler&#8221;</a> post) that you can use the SystemManager class instead of all my references to <code>Application.application</code>. Thanks Raghu!</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" applicationComplete="init()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import flash.display.StageDisplayState;
            import mx.managers.SystemManager;

            private function init():void {
                /* Set up full screen handler. */
                systemManager.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
                dispState = systemManager.stage.displayState;
            }

            private function fullScreenHandler(evt:FullScreenEvent):void {
                dispState = systemManager.stage.displayState + " (fullScreen=" + evt.fullScreen.toString() + ")";
                if (evt.fullScreen) {
                    /* Do something specific here if we switched to full screen mode. */
                } else {
                    /* Do something specific here if we switched to normal mode. */
                }
            }

            private function toggleFullScreen():void {
                try {
                    switch (systemManager.stage.displayState) {
                        case StageDisplayState.FULL_SCREEN:
                            /* If already in full screen mode, switch to normal mode. */
                            systemManager.stage.displayState = StageDisplayState.NORMAL;
                            break;
                        default:
                            /* If not in full screen mode, switch to full screen mode. */
                            systemManager.stage.displayState = StageDisplayState.FULL_SCREEN;
                            break;
                    }
                } catch (err:SecurityError) {
                    // ignore
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:String id="dispState" /&gt;

    &lt;mx:Label text="width={Application.application.width}" /&gt;
    &lt;mx:Label text="height={Application.application.height}" /&gt;
    &lt;mx:Label text="displayState={dispState}" /&gt;

    &lt;mx:Button label="Toggle fullscreen" click="toggleFullScreen()" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating full-screen Flex applications on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/',contentID: 'post-67',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'displayState',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/08/07/creating-full-screen-flex-applications/feed/</wfw:commentRss>
		<slash:comments>114</slash:comments>
		</item>
	</channel>
</rss>

