<?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>Serge Jespers &#187; updating</title>
	<atom:link href="http://www.webkitchen.be/tag/updating/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webkitchen.be</link>
	<description>Life as an Adobe platform evangelist</description>
	<lastBuildDate>Tue, 31 Jan 2012 17:35:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Updating AIR applications</title>
		<link>http://www.webkitchen.be/2008/06/16/updating-air-applications/</link>
		<comments>http://www.webkitchen.be/2008/06/16/updating-air-applications/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 09:54:57 +0000</pubDate>
		<dc:creator>Serge Jespers</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[onAIR Tour]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[onAIR]]></category>
		<category><![CDATA[tour]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[updater class]]></category>
		<category><![CDATA[updating]]></category>

		<guid isPermaLink="false">http://www.webkitchen.be/?p=144</guid>
		<description><![CDATA[My presentation at the On AIR tour through Europe was about signing, deploying and updating your AIR applications. If you didn&#8217;t make it to the tour or just want to read up on these topics, I wrote three separate posts about them on the train somewhere between Prague and Munich. This is probably the most [...]]]></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.webkitchen.be%2F2008%2F06%2F16%2Fupdating-air-applications%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.webkitchen.be%2F2008%2F06%2F16%2Fupdating-air-applications%2F&amp;source=sjespers&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f11b21ad05448f9b4029b73b124e8d0e&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="note">My presentation at the On AIR tour through Europe was about <a href="http://www.webkitchen.be/2008/06/16/signing-air-applications" target="_blank">signing</a>, <a href="http://www.webkitchen.be/2008/06/16/deploying-air-applications/" target="_blank">deploying</a> and <a href="http://www.webkitchen.be/2008/06/16/updating-air-applications/" target="_blank">updating</a> your AIR applications. If you didn&#8217;t make it to the tour or just want to read up on these topics, I wrote three separate posts about them on the train somewhere between Prague and Munich.</div>
<p>This is probably the most important step to take when you are building your application and it should probably be the first thing you do. Let&#8217;s say someone found a bug in your application and you fixed it in a newer version. How are you going to tell users about that bug-fix if you don&#8217;t have an update mechanism in place? AIR has everything on board to make updating applications a breeze, both for you and the user of your application.<br />
<span id="more-144"></span><br />
Whenever my application starts, it&#8217;s going to load an XML file from my server. That XML file describes the version I have on my server and I even added some release notes. This XML file can be structured any way you want it to be and can hold all the information you want in there. Working with XML files in AS3.0 and Flex has become a breeze compared to how it used to be. So no more firstChild.childNode[3].grandChild.bastardChild.attribute.version.</p>
<p>My application version XML file looks like this:<br />
<code>&lt;?xml version="1.0" ?&gt;<br />
&lt;application&gt;<br />
&lt;info version="2" downloadurl="http://localhost/version2.air" /&gt;<br />
&lt;releasenotes&gt;<br />
&lt;![CDATA[Fixed some bugs in this version]]&gt;<br />
&lt;/releasenotes&gt;<br />
&lt;/application&gt; </code></p>
<p>Loading an XML file in Flex, is as simple as this one line of code:<br />
<code>&lt;mx:HTTPService<br />
id="appversion_xml"<br />
url="http://localhost/onAIR/appversion.xml"<br />
showBusyCursor="true"<br />
resultFormat="e4x"<br />
result="checkForUpdate()"/&gt;</code></p>
<p>This creates an XML object with the name &#8220;appversion_xml&#8221;. Whenever the server sends back a result, the result event is fired which calls my checkForUpdate() function. I even show a little busy cursor to show the user that there&#8217;s something happening. E4X is the preferred result format.  Now to load the XML file when my application starts, I created an init function.</p>
<pre lang="actionscript">private function init():void
{
	appversion_xml.send();
}</pre>
<p>This gets called when my application is ready. Just add this attribute to your WindowedApplication node in Flex.</p>
<pre lang="actionscript">creationComplete="init()"</pre>
<p>So the next thing you need to do when your XML file is loaded, is check if the version on your server is different from the one you have installed.</p>
<pre lang="actionscript">var descriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = descriptor.namespaceDeclarations()[0];
currentVersion = descriptor.ns::version;</pre>
<p>This would get the version number of the version you have installed. This actually refers to your application descriptor XML file. The application descriptor file gets included in your application when you build it and is accessible through NativeApplication.nativeApplication.applicationDescriptor.</p>
<p>The version number that I got back from the server will be available in:</p>
<pre lang="actionscript">appversion_xml.lastResult..info.@version;</pre>
<p>Now I need to add a quick note here. The application version designator can be anything you want it be. It can be just a simple number but it can just as well be something like v3.79.3.222.beta.1.5.67.78. However, I find it a lot easier to use just plain and simple increasing numbers. These are a lot easier to compare to each other and thus make it a lot simpler for you to code.</p>
<pre lang="actionscript">if(Number(updateVersion) &gt; Number(currentVersion)) {
	//update available
}</pre>
<p>Now that&#8217;s a lot easier than having to create your own logic to compare your version designators.</p>
<p>So now that we know the version on my server is newer than the one I have installed so we have two options. You could just do the update without any user intervention, or you might want to let the user known that there is an update available and let him decide what he wants to do. In my demo application, I popup a little utility window that also displays the release notes from the XML file but you can let the user know about the options in however way you see fit.</p>
<p>We&#8217;re almost there. Now that we know the user wants to update the application we can go ahead and do so.<br />
So the first thing we need to do, is download the new update to the local machine. Since we are using AIR we have access to the desktop and so we can do this automatically. In the code below, I create a new instance of a URLStream and attach an eventListener to it. Whenever the URLStream is done, it&#8217;s going to execute the code to store it on the user&#8217;s machine. In this case we are going to store the update in the applicationStorageDirectory and rename it to update.air. Next we create a new instance of the Updater class and call it&#8217;s update method specifying the path to our update and its version number.</p>
<pre lang="actionscript">private function downloadUpdate(file:String):void
{
   downloadStream = new URLStream();
   downloadStream.addEventListener(Event.COMPLETE, function(evt:Event):void {
      myUpdateWin.statusText = "Downloading and installing the update";

      var appData:ByteArray = new ByteArray();
      downloadStream.readBytes(appData, 0, downloadStream.bytesAvailable);

      var updateFile:File = File.applicationStorageDirectory.resolvePath("upgrade.air");
      var fileStream:FileStream = new FileStream();

      fileStream.open(updateFile, FileMode.WRITE);
      fileStream.writeBytes(appData, 0, appData.length);
      fileStream.close();

      var appUpdate:Updater = new Updater();
      appUpdate.update(updateFile, updateVersion);
   });
   downloadStream.load(new URLRequest(file));
}</pre>
<p>The update method of the Updater class will close the application, launch the AIR installer to install the update and then relaunch the application. All without any intervention from the user! Completely transparent and easy for the end user.</p>
<p>That&#8217;s how easy it is to do it but to make it even easier, we&#8217;ve just <a href="http://labs.adobe.com/wiki/index.php/Adobe_AIR_Update_Framework" target="_blank">released an update framework</a> to simplify things even more. This framework works for both Flash/Flex based applications and Javascript/HTML based apps.</p>
<iframe id="basic_facebook_social_plugins_likebutton" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.webkitchen.be%2F2008%2F06%2F16%2Fupdating-air-applications%2F&amp;layout=standard&amp;show_faces=true&amp;width=500&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:75px"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.webkitchen.be/2008/06/16/updating-air-applications/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Signing AIR applications</title>
		<link>http://www.webkitchen.be/2008/06/16/signing-air-applications/</link>
		<comments>http://www.webkitchen.be/2008/06/16/signing-air-applications/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 09:30:17 +0000</pubDate>
		<dc:creator>Serge Jespers</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[onAIR Tour]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[deploying]]></category>
		<category><![CDATA[onAIR]]></category>
		<category><![CDATA[signing]]></category>
		<category><![CDATA[tour]]></category>
		<category><![CDATA[updating]]></category>

		<guid isPermaLink="false">http://www.webkitchen.be/?p=143</guid>
		<description><![CDATA[My presentation at the On AIR tour through Europe was about signing, deploying and updating your AIR applications. If you didn&#8217;t make it to the tour or just want to read up on these topics, I wrote three separate posts about them on the train somewhere between Prague and Munich. First of all, why is [...]]]></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.webkitchen.be%2F2008%2F06%2F16%2Fsigning-air-applications%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.webkitchen.be%2F2008%2F06%2F16%2Fsigning-air-applications%2F&amp;source=sjespers&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f11b21ad05448f9b4029b73b124e8d0e&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="note">My presentation at the On AIR tour through Europe was about <a href="http://www.webkitchen.be/2008/06/16/signing-air-applications" target="_blank">signing</a>, <a href="http://www.webkitchen.be/2008/06/16/deploying-air-applications/" target="_blank">deploying</a> and <a href="http://www.webkitchen.be/2008/06/16/updating-air-applications/" target="_blank">updating</a> your AIR applications. If you didn&#8217;t make it to the tour or just want to read up on these topics, I wrote three separate posts about them on the train somewhere between Prague and Munich.</div>
<p>First of all, why is signing an application important? Easy. When your application is unsigned or signed with a self-signed certificate, the user will get two red icons on the install screen. The first one is related to your code signing certificate. It&#8217;s telling you that the &#8220;publisher is unknown&#8221; which is very normal since we have no idea who actually signed this application.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-121 aligncenter" title="unknown" src="http://www.webkitchen.be/wp-content/uploads/2008/05/unknown.jpg" alt="" width="354" height="42" /></p>
<p>When you do get a code signing certificate and sign the application with it, the icon will turn green or in some cases yellow. The yellow icon will appear when you are using the file I/O API.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-120 aligncenter" title="known" src="http://www.webkitchen.be/wp-content/uploads/2008/05/known.jpg" alt="" width="354" height="31" /></p>
<p><span id="more-143"></span><br />
So where do you get a code signing certificate? Well, maybe you already have one. If you already bought one to sign Java or Cocoa applications for instance, chances are that this certificate is 100% compatible and you can use that. To make sure, check that your certificate is a Class 3 code signing certificate and you should be ready to go. If you don&#8217;t have, there&#8217;s a number of companies like Thawte.com that actually sell these. But if you upload your application to the <a href="http://www.adobe.com/go/marketplace" target="_blank">Adobe AIR marketplace</a>, you may get a complimentary code signing certificate from us. More info <a href="http://www.adobe.com/products/air/assets/popup/thawte_popup.html" target="_blank">here</a>.</p>
<p>I&#8217;m mainly using Flex for AIR development but the workflow is very similar in Flash or Dreamweaver. In case of Flex, you are actually going to build a release version of your application. To do that, you click the &#8220;export release build&#8221;-button. That will popup a little wizard window. In the first window, you can specify where you want to save your .AIR file. In this case, I&#8217;m saving it on the desktop.<br />
<a href="http://www.adobe.com/go/marketplace" target="_blank"></a></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-145 aligncenter" title="exportreleasebuild" src="http://www.webkitchen.be/wp-content/uploads/2008/06/exportreleasebuild.jpg" alt="" width="450" height="407" /></p>
<p>When you click &#8220;next&#8221;, Flex will ask you to specify which digital certificate you want to use. If you don&#8217;t have one but still want to build a .AIR file for testing, click on the &#8220;create&#8221; button. When you fill out all the details of that form, you can save that self signed certificate so you don&#8217;t have to fill out that form every time. I saved mine in my home folder. Once you have created it, you can easily reuse it by just entering your password.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-146 aligncenter" title="exportreleasebuild2" src="http://www.webkitchen.be/wp-content/uploads/2008/06/exportreleasebuild2.jpg" alt="" width="450" height="407" /></p>
<p>If you already have a code signing certificate, you can browse to the location you saved it to use it. Click &#8220;finish&#8221; and your AIR file is going to be baked. That&#8217;s it.</p>
<iframe id="basic_facebook_social_plugins_likebutton" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.webkitchen.be%2F2008%2F06%2F16%2Fsigning-air-applications%2F&amp;layout=standard&amp;show_faces=true&amp;width=500&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:75px"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.webkitchen.be/2008/06/16/signing-air-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

