<?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>Saturnboy &#187; flash</title>
	<atom:link href="http://saturnboy.com/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://saturnboy.com</link>
	<description>Code, Work, and Life</description>
	<lastBuildDate>Thu, 01 Mar 2012 22:35:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Metrics and the AIR Install Badge</title>
		<link>http://saturnboy.com/2010/05/metrics-air-install-badge/</link>
		<comments>http://saturnboy.com/2010/05/metrics-air-install-badge/#comments</comments>
		<pubDate>Wed, 19 May 2010 15:21:01 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flexmonkey]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=1405</guid>
		<description><![CDATA[The AIR Install Badge is a very handy little flash application for delivering AIR applications to your users via the web. The badge allows your users to download and install both your application and the Adobe AIR runtime. Additionally, the install badge will automatically prompt users to upgrade if a previously installed version is detected. [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.adobe.com/devnet/air/articles/badge_for_air.html">AIR Install Badge</a> is a very handy little flash application for delivering AIR applications to your users via the web.  The badge allows your users to download and install both your application and the Adobe AIR runtime.  Additionally, the install badge will automatically prompt users to upgrade if a previously installed version is detected.  At <a href="http://www.gorillalogic.com/">Gorilla Logic</a>, we use the AIR Install Badge on the <a href="http://www.gorillalogic.com/flexmonkey/download">FlexMonkey download page</a> (free registration required).</p>
<p>Alas, flash is opaque to analytics.  We have no idea what our users are doing inside the AIR Install Badge application.  Are they installing? Or upgrading?  No problem, we just need to write some code&#8230;</p>
<h3>The Code</h3>
<p>Using flash&#8217;s <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html">ExternalInterface</a>, we can manually push the data out of flash and into javascript.  Once we have the data in javascript, we have total control.  One option is to <a href="http://blog.creoff.net/using-google-analytics-with-adobe-air-install-badge/">use google analytics to store our badge data</a>.  In the case of FlexMonkey, we send the badge data along with the user&#8217;s credentials to our CRM platform, <a href="http://www.salesforce.com/">SalesForce.com</a>.</p>
<p class="bottom"><b>Step 1:</b> First, open <code>AIRInstallBadge.as</code> and add this to the top:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;</pre></div></div>

<p class="bottom"><b>Step 2:</b> Next, add the <code>ExternalInterface</code> call to the top of the <code>handleActinClick()</code> function in <code>AIRInstallBadge.as</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">protected <span style="color: #000000; font-weight: bold;">function</span> handleActionClick<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>action == <span style="color: #ff0000;">'install'</span> <span style="color: #66cc66;">||</span> action == <span style="color: #ff0000;">'upgrade'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">//send data to js</span>
        ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'badgeJS'</span>,action<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    ...
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Since I only care about the <code>install</code> or <code>upgrade</code> actions, I&#8217;ll only send those out to javascript.  Re-compile the badge and deploy.</p>
<p class="bottom"><b>Step 3:</b> Last, add the <code>badgeJS()</code> javascript callback to the page containing the badge and do whatever you want with the incoming badge data:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> badgeJS<span style="color: #009900;">&#40;</span>action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//do metrics here...</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'badge action='</span> <span style="color: #339933;">+</span> action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Conclusion</h3>
<p>With an hour of effort, and a very small amount of code, we&#8217;ve managed to get the useful metrics of installs and upgrades out of the AIR Install Badge and into our analytics engine of choice.  A job well done.</p>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2010/05/metrics-air-install-badge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

