<?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>Yeah, But Is It Flash?</title>
	<atom:link href="http://www.yeahbutisitflash.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.yeahbutisitflash.com</link>
	<description>Random musings about all things Flash related</description>
	<lastBuildDate>Sat, 12 May 2012 14:42:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3-RC3</generator>
		<item>
		<title>Managing the AIR SDK in Flash Professional CS6</title>
		<link>http://www.yeahbutisitflash.com/?p=4141</link>
		<comments>http://www.yeahbutisitflash.com/?p=4141#comments</comments>
		<pubDate>Sat, 12 May 2012 12:57:50 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=4141</guid>
		<description><![CDATA[Sometimes it&#8217;s the little things that make such a big difference. If you&#8217;ve been using Flash Professional CS5.5 then you&#8217;ll know what a chore it is to overlay the latest AIR SDK onto your installation. Well the good news is, if you upgrade to Flash Professional CS6 then all that hardship will be a thing [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4141"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4141&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes it&#8217;s the little things that make such a big difference. If you&#8217;ve been using Flash Professional CS5.5 then you&#8217;ll know what a chore it is to <a href="http://www.yeahbutisitflash.com/?p=2949" target="_blank">overlay the latest AIR SDK</a> onto your installation. Well the good news is, if you upgrade to Flash Professional CS6 then all that hardship will be a thing of the past.</p>
<p>It&#8217;s now possible to install and manage various AIR SDKs within Flash Professional CS6&#8242;s IDE. To show just how easy it is let&#8217;s walk through the steps involved to install the latest AIR 3.3 public beta.</p>
<ol>
<li>Download the <a href="http://labs.adobe.com/downloads/air3-3.html" target="_blank">Adobe AIR 3.3 SDK Beta</a> archive from Adobe Labs.</li>
<li>Copy the archive to your desktop and extract it to a folder.<br />
After unzipping you should be left with a folder named <code>air3-3_p3_sdk_win_050412</code> on your Windows desktop and a folder named <code>air3-3_p3_sdk_mac_050412</code> on Mac OSX.</li>
<li>Now launch Flash Professional CS6.</li>
<li>From Flash Professional select <strong>Help | Manage AIR SDK</strong> from it&#8217;s drop-down menu.
<div style="padding-top:12px; padding-bottom:12px;" align="center"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-1.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-1.png" alt="" title="screenshot-1" width="532" height="367" class="aligncenter size-full wp-image-4171" /></a></div>
</li>
<li>The <strong>Manage AIR SDK</strong> panel will appear. Click on the <strong>Add New SDK</strong> icon, which is represented by a <strong><code>+</code></strong> symbol. You&#8217;ll be asked to select an AIR SDK to be installed. Simply browse to your desktop and select the AIR 3.3 SDK folder.
<div style="padding-top:12px; padding-bottom:12px;" align="center"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-2.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-2.png" alt="" title="screenshot-2" width="466" height="241" class="aligncenter size-full wp-image-4147" /></a></div>
</li>
<li>The AIR 3.3 SDK will be added to the list of installed SDKs within the Manage AIR SDK panel.
<div style="padding-top:12px; padding-bottom:12px;" align="center"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-3.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-3.png" alt="" title="screenshot-3" width="466" height="241" class="aligncenter size-full wp-image-4148" /></a></div>
</li>
<li>Now click <strong>OK</strong> to close the panel.</li>
</ol>
<p>Congratulations, you&#8217;ve successfully installed the latest AIR SDK. Whenever you create a new AIR document within Flash Professional CS6, the AIR 3.3 SDK will be used by default. You can however revert back to the default AIR SDK, or select from any other versions of the AIR SDK that you have installed.</p>
<p>This can be done from either your FLA&#8217;s <strong>Properties</strong> panel, or from the <strong>Publish Settings</strong> panel. Simply select the desired SDK from the <strong>Target</strong> drop-down box. As you can see from the screenshot below, each AIR SDK can be used to target desktop, iOS, and Android.</p>
<div style="padding-top:12px; padding-bottom:12px;" align="center"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-4.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/05/screenshot-4.png" alt="" title="screenshot-4" width="299" height="552" class="aligncenter size-full wp-image-4149" /></a></div>
<p>So there you have it. Each new AIR SDK can be installed and used within Flash Professional CS6 with only a few simple steps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=4141</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Games for iOS</title>
		<link>http://www.yeahbutisitflash.com/?p=4126</link>
		<comments>http://www.yeahbutisitflash.com/?p=4126#comments</comments>
		<pubDate>Fri, 27 Apr 2012 23:32:30 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=4126</guid>
		<description><![CDATA[Frosby Design has just released its latest iOS kids educational app &#8211; Frosby Learning Games. It was developed using Adobe AIR and Flash Professional CS5.5, and has also been featured in Apple&#8217;s App Store in the US, UK, Australia and China. It&#8217;s a great little app for toddlers and young children, containing a collection of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4126"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4126&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>Frosby Design has just released its latest iOS kids educational app &#8211; <a href="http://itunes.apple.com/us/app/frosby-learning-games/id508094989?ls=1&#038;mt=8" target="_blank">Frosby Learning Games</a>. It was developed using Adobe AIR and Flash Professional CS5.5, and has also been featured in Apple&#8217;s App Store in the US, UK, Australia and China.</p>
<div align="center"><iframe width="560" height="315" src="http://www.youtube.com/embed/oBRjdpHkWy4" frameborder="0" allowfullscreen></iframe></div>
<p>It&#8217;s a great little app for toddlers and young children, containing a collection of fun activities to help with early learning skills and language. My little nephew had a brilliant time playing it. He laughed his little head off when we had to find mice hiding in a block of cheese, and also seemed to love feeding worms to a mole a little later on too.</p>
<p>For more details take a look at Frosby&#8217;s official <a href="https://www.facebook.com/FrosbyApps" target="_blank">Facebook page</a>. Also, Frosby Design is looking to hire London based Flash game developers to work with on future apps. If you have any ActionScript 3 game demos, then contact Matt Wasser at matt [at] frosby [dot] net.</p>
<p>Frosby Learning Games is available on iPhone, iPod touch, and iPad.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=4126</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excerpt on Adobe&#8217;s Developer Connection Site</title>
		<link>http://www.yeahbutisitflash.com/?p=4118</link>
		<comments>http://www.yeahbutisitflash.com/?p=4118#comments</comments>
		<pubDate>Wed, 25 Apr 2012 22:24:30 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Flash iOS Apps Cookbook]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=4118</guid>
		<description><![CDATA[I&#8217;m delighted to announce that, along with a photo of my big ugly mug, Adobe are currently featuring an excerpt from my Flash iOS Apps Cookbook. So if you&#8217;re undecided about making a purchase then why not head on over to their Developer Connection website where you can download Chapter 15, ActionScript Optimization in its [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4118"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4118&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;m delighted to announce that, along with a photo of my big ugly mug, Adobe are currently featuring an excerpt from my <a href="http://www.adobe.com/devnet/actionscript/articles/actionscript-optimization.html">Flash iOS Apps Cookbook</a>. So if you&#8217;re undecided about making a purchase then why not head on over to their <a href="http://www.adobe.com/devnet/actionscript/articles/actionscript-optimization.html">Developer Connection website</a> where you can download Chapter 15, ActionScript Optimization in its entirety. It&#8217;s full of practical code examples and good advice for squeezing the best performance out of your iOS apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=4118</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash iOS Apps Cookbook &#8211; The lost recipes</title>
		<link>http://www.yeahbutisitflash.com/?p=4063</link>
		<comments>http://www.yeahbutisitflash.com/?p=4063#comments</comments>
		<pubDate>Fri, 13 Apr 2012 23:47:50 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Flash iOS Apps Cookbook]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=4063</guid>
		<description><![CDATA[When writing a book there are many tough decisions to be made. Perhaps the most agonising for me was deciding what to keep and what to drop. With an agreed page count to stick to I found that I simply couldn&#8217;t cram everything I wanted to into my Flash iOS Apps Cookbook. So during the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4063"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D4063&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>When writing a book there are many tough decisions to be made. Perhaps the most agonising for me was deciding what to keep and what to drop. With an agreed page count to stick to I found that I simply couldn&#8217;t cram everything I wanted to into my <a href="http://www.yeahbutisitflash.com/?page_id=3371">Flash iOS Apps Cookbook</a>.</p>
<p>So during the revision process I went about cutting out certain code recipes that I felt I could probably do without. Some of them simply didn&#8217;t fit the structure of the book and were clear candidates. Others had limited real-world use cases, or weren&#8217;t aimed at the book&#8217;s target audience. In the end we probably removed around 100 pages worth of content.</p>
<p>I thought it would be worth resurrecting some of that material and making it available from my blog. There&#8217;s no particular order and some of it went through more revisions than others. I&#8217;ll start with a couple of recipes that were originally intended for Chapter 11, Rendering Web Pages. Both detail bi-directional ActionScript/JavaScript communication and are worth a read if you&#8217;re planning to make use of AIR&#8217;s <code>StageWebView</code> class. Anyway, enjoy and I&#8217;ll see what else I can dig out for you over the coming months.</p>
<ul>
<li><a href="?p=3968">ActionScript to JavaScript Communication</a></li>
<li><a href="?p=3996">JavaScript to ActionScript Communication</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=4063</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JavaScript to ActionScript Communication</title>
		<link>http://www.yeahbutisitflash.com/?p=3996</link>
		<comments>http://www.yeahbutisitflash.com/?p=3996#comments</comments>
		<pubDate>Fri, 13 Apr 2012 23:45:21 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Flash iOS Apps Cookbook]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3996</guid>
		<description><![CDATA[While ActionScript to JavaScript communication is straightforward, JavaScript to ActionScript communication is less obvious and somewhat limited when working with the StageWebView class. In this tutorial we&#8217;ll walk through the steps required to pass data from an HTML page to your AIR for iOS app. This tutorial is a previously unreleased recipe from Flash iOS [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3996"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3996&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>While ActionScript to JavaScript communication is straightforward, JavaScript to ActionScript communication is less obvious and somewhat limited when working with the <code>StageWebView</code> class.</p>
<p>In this tutorial we&#8217;ll walk through the steps required to pass data from an HTML page to your AIR for iOS app.</p>
<div style="height: 140px; border-top:1px dotted #555555; border-bottom:1px dotted #555555; padding-top:5px; padding-bottom:5px;">
<img alt="Flash iOS Apps Cookbook" src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/cookbook-cover.png" title="Flash iOS Apps Cookbook" width="105" height="130" class="alignleft size-full wp-image-4077" /><strong>This tutorial is a previously unreleased recipe from <a href="http://www.amazon.com/gp/product/184969138X/ref=s9_simh_gw_p14_d0_g14_i1?pf_rd_m=ATVPDKIKX0DER&#038;pf_rd_s=center-2&#038;pf_rd_r=18SPM3FGKR4M407BHZ2M&#038;pf_rd_t=101&#038;pf_rd_p=470938631&#038;pf_rd_i=507846" target="_blank">Flash iOS Apps Cookbook</a> and supplements the content found in Chapter 11, Rendering Web Pages.</strong></p>
<p>Flash iOS Apps Cookbook provides the recipes required to build native iOS apps using your existing knowledge of the Flash platform. Whether you want to create something new or simply convert an existing Flash project, the relevant steps and techniques are covered, helping you achieve your goal.
</p></div>
<h2>Getting ready</h2>
<p>As with the majority of recipes presented in this chapter, the steps covered here are only applicable to those using AIR 2.6 and above.</p>
<p>From this recipe&#8217;s <a href="http://www.yeahbutisitflash.com/downloads/flash-ios-apps-cookbook/chapter11.zip">accompanying code bundle</a>, open <code>chapter11\recipe8\recipe.fla</code> and use it as a starting point.</p>
<p>Included within the FLA&#8217;s AIR for iOS Settings is a folder named <code>html</code>, which contains the HTML page that will be used to pass data to your app. The HTML is basic and displays a form with two fields prompting the user for their forename and surname. When the user submits the form, a JavaScript function on the page will attempt to pass the value of both fields to your AIR for iOS app.</p>
<p>Sitting on the stage is a dynamic text field with an instance name of <code>output</code>. We&#8217;ll use this to display the data retrieved from the HTML page.</p>
<p>Before proceeding, use a text editor of your choice to familiarize yourself with the HTML and its JavaScript. It can be found at <code>chapter11\recipe8\html\index.html</code>.</p>
<p>Now let&#8217;s write some ActionScript to retrieve the data.</p>
<h2>How to do it&#8230;</h2>
<p>Perform the following steps:</p>
<ol>
<li>Create a new document class and name it <code>Main</code>.</li>
<li>Add the following import statements:<br />
<blockquote>
<pre><code>import flash.events.LocationChangeEvent;
import flash.filesystem.File;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.net.URLVariables;</code></pre>
</blockquote>
</li>
<li>Declare a <code>StageWebView</code> member variable:<br />
<blockquote>
<pre><code>private var webView:StageWebView;</code></pre>
</blockquote>
</li>
<li>Within the constructor, load <code>html/index.html</code> and listen for the <code>LOCATION_CHANGING</code> event being dispatched from the <code>StageWebView</code> object:<br />
<blockquote>
<pre><code>public function Main() {
  <font color='black'>var url:String = File.applicationDirectory.resolvePath(
    "html/index.html").nativePath;

  webView = new StageWebView();
  webView.stage = stage;
  webView.viewPort = new Rectangle(
    0, 0, stage.stageWidth, stage.stageHeight);
  webView.addEventListener(
    LocationChangeEvent.LOCATION_CHANGING, locationChanging);
  webView.loadURL(url);</font>
}</code></pre>
</blockquote>
</li>
<li>Finally, add a handler for the <code>LOCATION_CHANGING</code> event, which will obtain the data passed from the HTML page and display it on screen:<br />
<blockquote>
<pre><code>private function locationChanging(e:LocationChangeEvent):void {
  var arr:Array = e.location.split(".html?");
  var vars:URLVariables = new URLVariables(arr[1]);
  output.text = (vars.first + " " + vars.last);
  webView.stage = null;
  webView.dispose();
  e.preventDefault();
}</code></pre>
</blockquote>
</li>
<li>Save the class and when prompted, name its file <code>Main.as</code>.</li>
<li>Move back to your FLA and save it too.</li>
<div id="attachment_4044" class="wp-caption center" style="width: 514px"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot11.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot11.png" alt="" title="screenshot1" width="504" height="455" class="size-full wp-image-4044" /></a><p class="wp-caption-text">Receiving text from an HTML page.</p></div>
<li>Now publish the FLA and test it on your device. Once the HTML page loads, enter your forename and surname into the form&#8217;s fields, then tap the <strong>Submit</strong> button. The HTML page will disappear from view and the value of both fields will be written to the <code>output</code> text field.</li>
</ol>
<h2>How it works&#8230;</h2>
<p>It&#8217;s possible to pass data from an HTML page to an AIR for iOS app by making use of the <code>StageWebView</code> class&#8217; <code>location</code> property and the <code>LOCATION_CHANGING</code> event. This is achieved by having JavaScript change the page&#8217;s location to a URL that contains encoded data. The changed URL can then be obtained from the <code>LOCATION_CHANGING</code> event&#8217;s handler and the data extracted from it.</p>
<p>Here&#8217;s the JavaScript function from <code>index.html</code>:</p>
<blockquote>
<pre><code>&lt;script type="text/javascript"&gt;
  function passData() {
    document.location = (
      "?first=" + encodeURIComponent(field1.value) +
      "&#038;last="  + encodeURIComponent(field2.value));
  }
&lt;/script&gt;</code></pre>
</blockquote>
<p>This function is called when the user presses the <strong>Submit</strong> button on the page. Notice that it sets <code>document.location</code> to an encoded string of name-value pairs. The two fields within the HTML page&#8217;s form have IDs of <code>field1</code> and <code>field2</code> respectively, and the value of each is used to create the string.</p>
<p>For example, if the user was to enter <strong>Christopher</strong> into the first field and <strong>Caleb</strong> into the second, then the JavaScript function would set <code>document.location</code> to the following:</p>
<blockquote>
<pre><code>?first=Christopher&#038;last=Caleb</code></pre>
</blockquote>
<p>In addition, the absolute path to the current HTML document is also prefixed resulting in the location actually resembling the following:</p>
<blockquote><p><code>///var/mobile/Applications/4D7985D8-029A-4E03-85CC-E77ECD38C987/recipe8.app/html/index.html?first=Christopher&#038;last=Caleb</code></p></blockquote>
<p>When the JavaScript changes the document&#8217;s location, the <code>StageWebView</code> object will dispatch a <code>LOCATION_CHANGING</code> event, which will be captured by the <code>locationChanging()</code> handler. The data can then be retrieved by querying the event&#8217;s <code>location</code> property. Since name-value pairs are used to represent the data, we can use Flash&#8217;s <code>URLVariables</code> class to easily extract the value of each:</p>
<blockquote>
<pre><code>private function locationChanging(e:LocationChangeEvent):void {
  var arr:Array = e.location.split(".html?");
  var vars:URLVariables = new URLVariables(arr[1]);
  output.text = (vars.first + " " + vars.last);
  webView.stage = null;
  webView.dispose();
  e.preventDefault();
}</code></pre>
</blockquote>
<p>In the code snippet above, the <code>split()</code> method is used to extract the name-value pairs from the location&#8217;s string. The name-value pairs are then passed to the <code>URLVariable</code> class&#8217; constructor.</p>
<p>Although the JavaScript function changed the page&#8217;s <code>location</code> property, we have no desire to actually move to a new page &#8211; we simply needed a mechanism for passing data. A call is therefore made to the event object&#8217;s <code>preventDefault()</code> method, stopping the new URL from actually loading. This is convenient as the new URL simply contains data and would result in a load error if the operation was to commence.</p>
<p>Also, this recipe used name-value pairs, but you can just as easily use some other data format such as JSON.</p>
<p>For more information regarding the <code>URLVariables</code> class, perform a search within Adobe Community Help.</p>
<h2>There&#8217;s more</h2>
<p>You may find bi-directional ActionScript/JavaScript communication cumbersome when using the <code>StageWebView</code> class. There is however, a third-party library available that removes much of the pain.</p>
<h3>StageWebView Bridge</h3>
<p>StageWebViewBridge is an extended version of the <code>StageWebView</code> class. It makes working with HTML content easier by providing an API that lets you do the following:</p>
<ul>
<li>Call JavaScript functions from ActionScript</li>
<li>Call ActionScript functions from JavaScript</li>
<li>Load local files and resources</li>
</ul>
<p>Although these things can already be done using <code>StageWebView</code>, the <code>StageWebViewBridge</code> class provides a layer of abstraction that helps remove much of the effort involved.</p>
<p>You can obtain the latest version of <code>StageWebViewBridge</code> from its Google Code Project page at <a href="http://code.google.com/p/stagewebviewbridge" target="_blank">code.google.com/p/stagewebviewbridge</a>.</p>
<h2>See also</h2>
<ul>
<li><em><a href="?p=3968">ActionScript to JavaScript communication</a>, Chapter 11</em></li>
<li><em>Rendering a local web page, <a href="http://www.amazon.com/Flash-Apps-Cookbook-Christopher-Caleb/dp/184969138X/ref=sr_1_1?ie=UTF8&#038;qid=1334174771&#038;sr=8-1" target="_blank">Chapter 11 of Flash iOS Apps Cookbook</a></em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3996</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript to JavaScript Communication</title>
		<link>http://www.yeahbutisitflash.com/?p=3968</link>
		<comments>http://www.yeahbutisitflash.com/?p=3968#comments</comments>
		<pubDate>Fri, 13 Apr 2012 23:37:46 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Flash iOS Apps Cookbook]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3968</guid>
		<description><![CDATA[Although limited, the StageWebView class makes it possible for an app to directly call a JavaScript function embedded within an HTML page. Let&#8217;s walk through the steps required to call a JavaScript function from ActionScript. This tutorial is a previously unreleased recipe from Flash iOS Apps Cookbook and supplements the content found in Chapter 11, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3968"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3968&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>Although limited, the <code>StageWebView</code> class makes it possible for an app to directly call a JavaScript function embedded within an HTML page.</p>
<p>Let&#8217;s walk through the steps required to call a JavaScript function from ActionScript.</p>
<div style="height: 140px; border-top:1px dotted #555555; border-bottom:1px dotted #555555; padding-top:5px; padding-bottom:5px;">
<img alt="Flash iOS Apps Cookbook" src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/cookbook-cover.png" title="Flash iOS Apps Cookbook" width="105" height="130" class="alignleft size-full wp-image-4077" /><strong>This tutorial is a previously unreleased recipe from <a href="http://www.amazon.com/gp/product/184969138X/ref=s9_simh_gw_p14_d0_g14_i1?pf_rd_m=ATVPDKIKX0DER&#038;pf_rd_s=center-2&#038;pf_rd_r=18SPM3FGKR4M407BHZ2M&#038;pf_rd_t=101&#038;pf_rd_p=470938631&#038;pf_rd_i=507846" target="_blank">Flash iOS Apps Cookbook</a> and supplements the content found in Chapter 11, Rendering Web Pages.</strong></p>
<p>Flash iOS Apps Cookbook provides the recipes required to build native iOS apps using your existing knowledge of the Flash platform. Whether you want to create something new or simply convert an existing Flash project, the relevant steps and techniques are covered, helping you achieve your goal.
</p></div>
<h2>Getting ready</h2>
<p>You&#8217;ll need AIR 2.6 or above for this recipe.</p>
<p>From this recipe’s <a href="http://www.yeahbutisitflash.com/downloads/flash-ios-apps-cookbook/chapter11.zip">accompanying code bundle</a>, open <code>chapter11\recipe7\recipe.fla</code> and use it as a starting point.</p>
<p>Bundled within the FLA&#8217;s AIR for iOS settings is an HTML file named <code>index.html</code>. Embedded within the HTML is a JavaScript function named <code>setMessage()</code>, which takes a string argument and writes it to the HTML page.</p>
<p>Sitting on the FLA&#8217;s stage is an input text field named <code>inputField</code> and a movie clip with an instance name of <code>updateBtn</code>. When the user taps the <code>updateBtn</code> movie clip, we&#8217;ll send any text within <code>inputField</code> to the HTML page&#8217;s <code>setMessage()</code> function.<br />
<div id="attachment_4014" class="wp-caption center" style="width: 570px"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot1.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot1.png" alt="" title="screenshot1" width="560" height="526" class="size-full wp-image-4014" /></a><p class="wp-caption-text">View of your FLA's stage.</p></div>Essentially, we&#8217;ll write code to pass a message entered within the app directly to a <code>StageWebView</code> object&#8217;s HTML, where it will be displayed.</p>
<p>Before proceeding, use a text editor of your choice to familiarize yourself with the HTML and its JavaScript. It can be found at <code>chapter11\recipe7\html\index.html</code>.</p>
<p>Let&#8217;s go ahead and write this recipe&#8217;s ActionScript.</p>
<h2>How to do it&#8230;</h2>
<p>Perform the following steps:</p>
<ol>
<li>Create a new document class and name it <code>Main</code>.</li>
<li>Add the following import statements and declare a <code>StageWebView</code> member variable:<br />
<blockquote>
<pre><code>package {

  import flash.display.MovieClip;
  <font color='black'>import flash.events.MouseEvent;
  import flash.filesystem.File;
  import flash.geom.Rectangle;
  import flash.media.StageWebView;</font>

  public class Main extends MovieClip {

    <font color='black'>private var webView:StageWebView;</font>

    public function Main() {
      // constructor code
    }
  }
}</code></pre>
</blockquote>
</li>
<li>Within the constructor, load the local web page and listen for the <code>updateBtn</code> movie clip being pressed. Position the web page&#8217;s viewport below the movie clip:<br />
<blockquote>
<pre><code>public function Main() {
  <font color='black'>var url:File = File.applicationDirectory.resolvePath(
    "html/index.html");

  webView = new StageWebView();
  webView.stage = stage;
  webView.viewPort = new Rectangle(
    0, 160, stage.stageWidth, stage.stageHeight-160);
  webView.loadURL(url.nativePath);

  updateBtn.addEventListener(MouseEvent.MOUSE_UP, pressed);</font>
}</code></pre>
</blockquote>
</li>
<li>Finally, add the <code>updateBtn</code> movie clip&#8217;s event handler. Within it, call the web page&#8217;s <code>setMessage()</code> JavaScript function, passing it any text entered by the user:<br />
<blockquote>
<pre><code>private function pressed(e:MouseEvent):void {
  var message:String = encodeURIComponent(inputField.text);
  webView.loadURL(
    "javascript:setMessage('" + message + "');");
}</code></pre>
</blockquote>
</li>
<li>Save the class and name its file <code>Main.as</code> when prompted.</li>
<li>Move back to your FLA and save it.</li>
<div id="attachment_4023" class="wp-caption center" style="width: 514px"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot2.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/screenshot2.png" alt="" title="screenshot2" width="504" height="454" class="size-full wp-image-4023" /></a><p class="wp-caption-text">Passing text to an HTML page.</p></div>
<li>Publish the FLA and test it on your device. Enter some text into the input text field and tap the <strong>Update text</strong> button. The text will be sent to the HTML page where it will be displayed.</li>
</ol>
<h2>How it works&#8230;</h2>
<p>ActionScript to JavaScript communication is performed via the <code>StageWebView</code> class&#8217; <code>loadURL()</code> method. Once a page is fully loaded you can use the <code>javascript:</code> URI scheme to invoke any functions that are declared within a <code>StageWebView</code> object&#8217;s web page. Take a look at the following example:</p>
<blockquote><p><code>webView.loadURL("javascript:doSomething();");</code></p></blockquote>
<p>This will call a JavaScript function named <code>doSomething()</code>.</p>
<p>Parameters can also be passed:</p>
<blockquote><p><code>webView.loadURL("javascript:setName('Tom', 'Waits');");</code></p></blockquote>
<p>The call above passes two strings to a <code>setName()</code> function &#8211; <strong>Tom</strong> and <strong>Waits</strong>.</p>
<p>For this recipe, the text entered by the user was passed to the HTML page&#8217;s <code>setMessage()</code> JavaScript function. First it was URL-encoded using Flash&#8217;s top-level <code>encodeURIComponent()</code> function:</p>
<blockquote>
<pre><code>var message:String = encodeURIComponent(inputField.text);
webView.loadURL("javascript:setMessage('" + message + "');");</code></pre>
</blockquote>
<p>All strings passed from ActionScript to JavaScript should be URL-encoded, since certain characters, such as spaces, can cause problems for the <code>StageWebView</code> object&#8217;s URL parser. This is a common mistake and can be difficult to track. Take the following call as an example:</p>
<blockquote>
<pre><code>webView.loadURL("javascript:setMessage('Hello World');");</code></pre>
</blockquote>
<p>This will fail due to the un-encoded space within the string <strong>Hello World</strong>. The following is correct:</p>
<blockquote>
<pre><code>var message:String = encodeURIComponent("Hello World");
webView.loadURL("javascript:setMessage('" + message + "');");</code></pre>
</blockquote>
<p>Be careful when making calls to JavaScript. No errors are thrown if the function you are calling doesn&#8217;t exist or throws a run-time error. Your call will simply silently fail, making debugging difficult.</p>
<p>It&#8217;s also not possible to directly receive a return value from a JavaScript function using <code>loadURL()</code>. You&#8217;ll need to apply a little creative coding if you want to receive data from the JavaScript-side. Take a look at the next recipe, <em><a href="?p=3996">JavaScript to ActionScript communication</a></em>, for more detail.</p>
<h2>There&#8217;s more&#8230;</h2>
<p>Here&#8217;s some additional detail.</p>
<h3>Calling in response to page events</h3>
<p>For this recipe we made our JavaScript call in response to the user pressing a button. It is however, perfectly acceptable to make a call as soon as an HTML page loads by listening for either <code>Event.COMPLETE</code> or <code>LocationChangeEvent.LOCATION_CHANGE</code> being dispatched by the <code>StageWebView</code> object.</p>
<h3>Calling built-in JavaScript functions</h3>
<p>It&#8217;s not possible to directly invoke JavaScript&#8217;s built-in functions using the <code>loadURL()</code> method. For example:</p>
<blockquote><p><code>webView.loadURL("javascript:alert('Hello World');");</code></p></blockquote>
<p>This line of ActionScript will not force an alert dialog to appear within the <code>StageWebView</code>. Instead the <code>alert()</code> would have to be placed inside a custom function that exists on the page.</p>
<h3>JavaScript injection</h3>
<p>JavaScript injection cannot be performed using the <code>loadURL()</code> method either. Take a look at the following:</p>
<blockquote><p><code>webView.loadURL("javascript:var name='Christopher';");</code></p></blockquote>
<p>The above attempt will fail to declare and initialize a variable called <code>name</code>.</p>
<h2>See also</h2>
<ul>
<li><em><a href="?p=3996">JavaScript to ActionScript communication</a></em></li>
<li><em>Rendering a local web page, <a href="http://www.amazon.com/Flash-Apps-Cookbook-Christopher-Caleb/dp/184969138X/ref=sr_1_1?s=books&#038;ie=UTF8&#038;qid=1334171485&#038;sr=1-1" target="_blank">Chapter 11 of Flash iOS Apps Cookbook</a></em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3968</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Map Native Extensions</title>
		<link>http://www.yeahbutisitflash.com/?p=3961</link>
		<comments>http://www.yeahbutisitflash.com/?p=3961#comments</comments>
		<pubDate>Wed, 11 Apr 2012 23:08:04 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Native Extensions]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[MapKit]]></category>
		<category><![CDATA[native extensions]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3961</guid>
		<description><![CDATA[Looking for mapping within your AIR for iOS projects? Then you should take a look at this native extension by Rares Neamtiu. It leveridges the iOS Map Kit framework to provide maps directly within your application. Rares has also recently added some new features to the extension including enhanced marker and events support. Mark Doherty [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3961"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3961&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>Looking for mapping within your AIR for iOS projects? Then you should take a look at this <a href="http://code.google.com/p/air-maps-ane/" target="_blank">native extension</a> by Rares Neamtiu. It leveridges the iOS Map Kit framework to provide maps directly within your application. Rares has also recently added some new features to the extension including enhanced marker and events support. Mark Doherty originally showed off a <a href="http://vimeo.com/29101190" target="_blank">video demonstration this extension</a> last year, so it&#8217;s great to see it being actively updated. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3961</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Profiling with Monocle</title>
		<link>http://www.yeahbutisitflash.com/?p=3950</link>
		<comments>http://www.yeahbutisitflash.com/?p=3950#comments</comments>
		<pubDate>Tue, 10 Apr 2012 09:29:29 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[monocle]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[stage3D]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3950</guid>
		<description><![CDATA[If you&#8217;ve been targeting mobile with the Flash platform or taking advantage of Stage3D on desktop then you&#8217;ll no doubt appreciate the need for good profiling tools. Mac OS X users have the excellent Instruments tool to help when developing for AIR for iOS but what about other mobile platforms or if you&#8217;re developing from [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3950"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3950&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>If you&#8217;ve been targeting mobile with the Flash platform or taking advantage of Stage3D on desktop then you&#8217;ll no doubt appreciate the need for good profiling tools. Mac OS X users have the excellent Instruments tool to help when developing for AIR for iOS but what about other mobile platforms or if you&#8217;re developing from a Windows machine? Well of course there&#8217;s the profiler that Adobe provides with Flash Builder and other excellent IDEs such as Flash Develop also have their own profiler but to be honest they&#8217;re all rather shallow when you consider the great features the Flash platform has to offer these days.</p>
<p>Thankfully Adobe are working on an advanced profiler named Monocle that will allow developers to debug at a very low level. It will allow you to profile live SWFs from the release version of the Flash player and will also work on mobile devices too. As your content runs, all sorts of information is sent to Monocle, including any Stage3D calls being made on the GPU. You can even step through each of the individual calls and watch the construction of each frame step by step. It&#8217;s all pretty impressive stuff and if you&#8217;d like to know more then I&#8217;d encourage you to take a look at the <a href="https://adobechats.adobeconnect.com/_a200985228/p4khwz03sz9/?launcher=false&#038;fcsContent=true&#038;pbMode=normal" target="_blank">recording of Lee Brimelow&#8217;s session</a> for the Denver Flash user&#8217;s group. He demos Monocle around the 37 minute mark but the whole video is definately worth watching.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3950</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Introduction to Starling and Sprite Sheets</title>
		<link>http://www.yeahbutisitflash.com/?p=3936</link>
		<comments>http://www.yeahbutisitflash.com/?p=3936#comments</comments>
		<pubDate>Sun, 08 Apr 2012 23:19:49 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Starling]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3936</guid>
		<description><![CDATA[The April issue of Flash &#038; Flex Developer&#8217;s magazine is now available and includes my second Starling framework tutorial. It covers some of Starling&#8217;s display list basics and demonstrates how to create animation with the use of sprite sheets. Just head over to the magazine&#8217;s offical website where you can download the latest issue for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3936"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3936&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>The April issue of <a href="http://ffdmag.com/magazine/1797-working-with-sprite-sheets-in-starling" target="_blank">Flash &#038; Flex Developer&#8217;s magazine</a> is now available and includes my second Starling framework tutorial. It covers some of Starling&#8217;s display list basics and demonstrates how to create animation with the use of sprite sheets.</p>
<div align="center"><a href="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/ffm-magazine-2b.png"><img src="http://www.yeahbutisitflash.com/wp-content/uploads/2012/04/ffm-magazine-2b.png" alt="" title="ffm-magazine-2b" width="350" class="aligncenter size-full wp-image-3945" /></a></div>
<p>Just head over to the <a href="http://ffdmag.com/magazine/1797-working-with-sprite-sheets-in-starling" target="_blank">magazine&#8217;s offical website</a> where you can download the latest issue for free. Oh and if you&#8217;d like to see what you&#8217;ll actually be creating then take a look at <a href="http://vimeo.com/39308902" target="_blank">this video</a>, which shows a slightly altered version I put together for iPad.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3936</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overlaying AIR 3.2 for Flash Professional CS5.5</title>
		<link>http://www.yeahbutisitflash.com/?p=3932</link>
		<comments>http://www.yeahbutisitflash.com/?p=3932#comments</comments>
		<pubDate>Tue, 03 Apr 2012 22:43:17 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Professional]]></category>

		<guid isPermaLink="false">http://www.yeahbutisitflash.com/?p=3932</guid>
		<description><![CDATA[AIR 3.2 has been released so it&#8217;s time once again for me to update my AIR Overlay tutorial for Flash Professional CS5.5 users. So if you&#8217;d like to use the AIR 3.2 SDK from within Flash Professional then click through to the following post: Overlaying AIR 3.2 SDK for Flash Professional CS5.5.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3932"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.yeahbutisitflash.com%2F%3Fp%3D3932&amp;source=chriscaleb&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>AIR 3.2 has been released so it&#8217;s time once again for me to update my AIR Overlay tutorial for Flash Professional CS5.5 users.</p>
<p>So if you&#8217;d like to use the AIR 3.2 SDK from within Flash Professional then click through to the following post: <a href="http://www.yeahbutisitflash.com/?p=2949">Overlaying AIR 3.2 SDK for Flash Professional CS5.5</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yeahbutisitflash.com/?feed=rss2&#038;p=3932</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

