<?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; FullScreenEvent</title>
	<atom:link href="http://blog.flexexamples.com/category/fullscreenevent/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</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>

