{"id":39,"date":"2009-09-28T02:05:00","date_gmt":"2009-09-28T07:05:00","guid":{"rendered":"http:\/\/lukerymarz.com\/alearningexperience\/2009\/09\/facebook-api-going-full-screen-with-adobe-flex.html"},"modified":"2010-04-25T16:14:57","modified_gmt":"2010-04-25T21:14:57","slug":"facebook-api-going-full-screen-with-adobe-flex","status":"publish","type":"post","link":"http:\/\/lukerymarz.com\/alearningexperience\/2009\/09\/facebook-api-going-full-screen-with-adobe-flex.html","title":{"rendered":"Facebook API: Going Full Screen with Adobe Flex"},"content":{"rendered":"<p>I&#8217;ve recently been checking out the Facebook API and doing some experiments with the <a href=\"http:\/\/code.google.com\/p\/facebook-actionscript-api\/\">Facebook ActionScript API<\/a>.  It&#8217;s relatively straightforward to use, but as I&#8217;ve found with other Adobe products, is a little lacking in documentation.  Using full screen mode is one of those things.  If you do a Google search for it, a lot of results talk about how it isn&#8217;t possible, but I&#8217;ve sorted it out, and here&#8217;s what I did to get it working.<\/p>\n<div><\/p>\n<div>First off, you&#8217;ll notice on the <a href=\"http:\/\/www.adobe.com\/devnet\/facebook\/articles\/iframe_fbml_flash_platform_comparison.html\">Adobe documentation<\/a> that full screen mode is supported only if you&#8217;re using Iframe content and not FBML.  This is the only place I found where it is indicated that it IS in fact supported.  I couldn&#8217;t find any example code on the subject.<\/div>\n<div><\/div>\n<div>Secondly, I went through the Adobe tutorials for <a href=\"http:\/\/www.adobe.com\/devnet\/facebook\/articles\/build_your_first_facebook_app.html\">Creating a Facebook app<\/a> and then <a href=\"http:\/\/www.adobe.com\/devnet\/facebook\/articles\/deploy_your_first_facebook_app.html\">Deploying your Facebook app<\/a>.  Jeanette&#8217;s coding style makes me crazy, but the examples are easy to work through.<\/div>\n<div>After the tutorials, you&#8217;re 95% of the way there.  We have to make two changes, the first is to add support to your Flex app to switch to full screen mode, and the second is to change your canvas page to enable full screen mode.<\/div>\n<div><\/div>\n<div><b><u>Changes to your Flex App<\/u><\/b><\/div>\n<div>You&#8217;ll need to add the ability to switch into full screen mode.  This is very simple, and is documented pretty well <a href=\"http:\/\/blog.flexexamples.com\/2007\/08\/07\/creating-full-screen-flex-applications\/\">here<\/a>.  What I did was add a button with a handler that set the stage display state:<\/div>\n<div><\/div>\n<div><i>ActionScript code<\/i><\/div>\n<div>private function toggleFullScreen():void <\/div>\n<div>{<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>try <\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>{<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">  <\/span>switch (this.stage.displayState) <\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">  <\/span>{<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">   <\/span>case StageDisplayState.FULL_SCREEN:<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">    <\/span>this.stage.displayState = StageDisplayState.NORMAL;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">    <\/span>break;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">   <\/span>default:<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">    <\/span>this.stage.displayState = StageDisplayState.FULL_SCREEN;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">    <\/span>break;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">  <\/span>}<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>} <\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>catch (err:SecurityError) <\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>{<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">  <\/span>\/\/ ignore<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\"> <\/span>}<\/div>\n<div>}<\/div>\n<p><\/p>\n<div><i>mxml code<\/i><\/div>\n<p>&lt;mx:LinkButton x=&#8221;534&#8243; y=&#8221;4&#8243; label=&#8221;FullScreen&#8221; click=&#8221;toggleFullScreen()&#8221;\/&gt;<\/p><\/div>\n<div><\/p>\n<div><b><u><span class=\"Apple-style-span\" style=\"font-style: normal;\">Changes to index.<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">htm<\/span><\/u><\/b><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\">This was the part I found a little tricky.  My HTML\/JavaScript skills are a little lacking, so I had to do a bit of reading to sort this out.<\/span><\/div>\n<div><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\">The index.htm you end up with at the end of the <\/span><a href=\"http:\/\/www.adobe.com\/devnet\/facebook\/articles\/deploy_your_first_facebook_app.html\"><span class=\"Apple-style-span\" style=\"font-style: normal;\">Adobe tutorial<\/span><\/a><span class=\"Apple-style-span\" style=\"font-style: normal;\"> allows you to debug your app AND deploy it to Facebook using the same html.  This is useful compared to the default html Flex Builder generates, which always opens a second web page to allow the user to log in.  This is all good, except the index.htm you end up with uses swfobject.embedSWF instead of the Adobe generated &lt;object&gt; and &lt;embed&gt; and tags people are probably used to.  Enabling full screen mode in the Adobe default html template is documented <\/span><a href=\"http:\/\/blog.flexexamples.com\/2007\/08\/07\/creating-full-screen-flex-applications\/\"><span class=\"Apple-style-span\" style=\"font-style: normal;\">here<\/span><\/a><span class=\"Apple-style-span\" style=\"font-style: normal;\">.<\/span><\/div>\n<div><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\">To enable it using swfobject.embedSWF, you have to pass it as an argument to the javascript function.  It seems obvious at first, the you&#8217;d just set flashVars.enableFullScreen to &#8220;<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">true&#8221; and be done, but that doesn&#8217;t work.  The enableFullScreen flag is set in the params argument, not the flashvars argument.  So what you started with:<\/span><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\"><br \/><\/span><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\">swfobject<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">.<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">embedSWF<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">(&#8220;<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">helloUser<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">.<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">swf<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">&#8220;, &#8220;<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">flashContent<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">&#8220;, &#8220;100%&#8221;, &#8220;100%&#8221;, &#8220;9.0.0&#8221;, &#8220;<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">expressInstall<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">.<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">swf<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">&#8220;, <\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">flashVars<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">);<\/span><\/div>\n<div><\/div>\n<div>E<span class=\"Apple-style-span\" style=\"font-style: normal;\">nds up being:<\/span><\/div>\n<div>\n<div><span class=\"Apple-style-span\"  style=\"color:#3333FF;\"><b>var params = {};<\/b><\/span><\/div>\n<div><span class=\"Apple-style-span\"  style=\"color:#3333FF;\"><b>params.allowfullscreen = &#8220;true&#8221;;<\/b><\/span><\/div>\n<div><span class=\"Apple-style-span\"  style=\"color:#3333FF;\">swfobject.embedSWF(&#8220;helloUser.swf&#8221;, &#8220;flashContent&#8221;, &#8220;100%&#8221;, &#8220;100%&#8221;, &#8220;9.0.0&#8221;, &#8220;expressInstall.swf&#8221;, flashVars, <b>params, false<\/b>);<\/span><\/div>\n<div><span class=\"Apple-style-span\"  style=\"color:#3333FF;\"><br \/><\/span><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-style: normal;\">That&#8217;s the key really.  I fought with the <\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">parameters<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\"> a bit before figuring out that I was setting <\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">enableFullScreen<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\"> in the wrong place.  I makes sense after looking through the <\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\">swfobject<\/span><span class=\"Apple-style-span\" style=\"font-style: normal;\"> documentation and comparing it to the index.template.html, but it&#8217;s not obvious to folk like me who sometimes struggle a bit with HTML and JavaScript.<\/span><\/div>\n<div><\/div>\n<\/div>\n<div>Now when you run your app in debug mode or on Facebook, it should switch into full screen mode when you toggle it, rather than doing nothing (as I was having it to for quite a while).<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently been checking out the Facebook API and doing some experiments with the Facebook ActionScript API. It&#8217;s relatively straightforward to use, but as I&#8217;ve found with other Adobe products, is a little lacking in documentation. Using full screen mode is one of those things. If you do a Google search for it, a lot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10,8,4],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-adobe-flex","category-flex","category-html"],"_links":{"self":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":1,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":47,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/posts\/39\/revisions\/47"}],"wp:attachment":[{"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lukerymarz.com\/alearningexperience\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}