<?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>Fraser Crosbie: Calgary Web Developer</title>
	<atom:link href="http://www.flashdev.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flashdev.ca</link>
	<description>Specializing in rich internet applications. Located in Calgary, Alberta, Canada</description>
	<lastBuildDate>Wed, 04 Apr 2012 04:14:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Fonts: OpenType vs TrueType</title>
		<link>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/</link>
		<comments>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 22:16:18 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=318</guid>
		<description><![CDATA[I came across a great article today written by Miguel Sousa about the benefits of OpenType (.otf) over TrueType (.ttf) fonts. I never put much thought into the difference between the two font extensions, although I have always leaned towards using OpenType fonts when available knowing that is a more recent format. Miguel goes into [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a great article today written by Miguel Sousa about the benefits of OpenType (.otf) over TrueType (.ttf) fonts. I never put much thought into the difference between the two font extensions, although I have always leaned towards using OpenType fonts when available knowing that is a more recent format. Miguel goes into great detail on the differences. The main difference that struck me the most as a RIA developer was that OpenType fonts can be up to 50% smaller than TrueType fonts. When embedding fonts or loading external fonts into a multilingual Flash application this piece of knowledge could trim off a significant amount of load time. Read more about the differences <a href="http://blogs.adobe.com/typblography/2010/12/the-benefits-of-opentypecff-over-truetype.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing Embedded Video In Reverse (Flash Player Bug)</title>
		<link>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/</link>
		<comments>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 16:47:38 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=303</guid>
		<description><![CDATA[On a recent project my team encountered a very annoying bug in ActionScript 3.0 when reversing the playback of an Embedded Video on the timeline. When playing the video forwards everything ran smooth, the processor usage remained low and the memory consumption remained low as well. When playing the video backwards, using mc.gotoAndStop(frame), the processor [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project my team encountered a very annoying bug in ActionScript 3.0 when reversing the playback of an Embedded Video on the timeline.</p>
<p>When playing the video forwards everything ran smooth, the processor usage remained low and the memory consumption remained low as well. When playing the video backwards, using mc.gotoAndStop(frame), the processor usage shot way up and the memory consumption went over a GB and in some cases over 2 GB.<br />
<span id="more-303"></span><br />
At first we figured it was due the the extra computing Flash Player needed to do in order to calculate the difference between keyframes in the video when playing it in reverse. FLVs are encoded to play forwards with a keyframe containing all the pixel data, then subsequent frames containing only the data of the pixels that have changed since the last keyframe. When playing in reverse Flash Player would need to read from multiple frames to determine how the current frame should be rendered. This takes additional processing power. The thing is, we had a keyframe on every single frame, so this could not be the issue.</p>
<p>Next we figured it might be due to smoothing the video. We needed to scale the video up and down so this was not something we could do without, but it was worth looking into anyways. We applied smoothing to the video, after loading it from an external SWF at runtime, by getting a reference to the Video object using this code:<br />
<code><br />
var videoFLV:Video = _video.getChildByName('flv') as Video;<br />
videoFLV.smoothing = true;<br />
</code><br />
We removed the smoothing and still no luck.</p>
<p>Finally we stumbled onto the issue by accident. When replacing the video on the timeline I forgot to give the Embedded Video object an instance name. All of the sudden the video was playing great in both directions but it did not have smoothing on because our code had no reference to the video object. When I added the instance name back, it ran slow again. After hours of tests and searching the internet for information, we figured it out. Adding an instance name to your video object will wreak havoc on your processor and memory usage when playing in reverse.</p>
<p>Our solution to re-add smoothing was to get a reference to the Embedded Video object using the following code:<br />
<code><br />
var videoFLV:Video = _video.getChildAt(0) as Video;<br />
videoFLV.smoothing = true;<br />
</code></p>
<p>I hope you find this article helpful and if you have any insight about this bug please comment.</p>
<p>Fraser <img src='http://www.flashdev.ca/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>P.S. I am not sure if it makes a difference, but we were using an ActionScript Project in Flash Builder 4 compiled for Flash Player 9.0.124.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The All-New 2011 Nissan Quest</title>
		<link>http://www.flashdev.ca/article/the-all-new-2011-nissan-quest/</link>
		<comments>http://www.flashdev.ca/article/the-all-new-2011-nissan-quest/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 05:33:21 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=270</guid>
		<description><![CDATA[The All-New 2011 Nissan Quest microsite launched today. I really enjoyed working on this project. All the people on my team were great and everything came together very smoothly. Make sure you check it out. http://www.nissanusa.com/microsite/quest/2011/]]></description>
			<content:encoded><![CDATA[<p>The All-New 2011 Nissan Quest microsite launched today. I really enjoyed working on this project. All the people on my team were great and everything came together very smoothly. Make sure you check it out.</p>
<p><a href="http://www.nissanusa.com/microsite/quest/2011/"><img src="http://www.flashdev.ca/wp-content/uploads/2010/11/quest2011-611x450.png" alt="" title="The All-New 2011 Nissan Quest" width="611" height="450" class="alignnone size-medium wp-image-276" /></a><br />
<a href="http://www.nissanusa.com/microsite/quest/2011/">http://www.nissanusa.com/microsite/quest/2011/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/the-all-new-2011-nissan-quest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Home Hardware Design Centre Launched</title>
		<link>http://www.flashdev.ca/article/home-hardware-design-centre-launched/</link>
		<comments>http://www.flashdev.ca/article/home-hardware-design-centre-launched/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 17:36:39 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=220</guid>
		<description><![CDATA[Home Hardware recently launched their Design Centre, a collection of applications geared towards helping homeowners research a huge range of products available at their local store. The Design Centre includes the Beauti-Tone Paint Home Designer and the Beauti-Tone Paint Colour Finder, which I blogged about in the previous post, as well as two new applications, [...]]]></description>
			<content:encoded><![CDATA[<p>Home Hardware recently launched their Design Centre, a collection of applications geared towards helping homeowners research a huge range of products available at their local store. The Design Centre includes the Beauti-Tone Paint Home Designer and the Beauti-Tone Paint Colour Finder, which I blogged about in the previous post, as well as two new applications, the HomeWorks Visualizer and Your Scrapbook.</p>
<p>HomeWorks Visualizer is similar to the Beauti-Tone Paint Home Designer in that it allows the customer to apply product to a variety of home exteriors and interior rooms, including kitchens, bathrooms, bedrooms and more. HomeWorks Visualizer includes a wide range of product categories including siding, stucco, brick, stone, roofing, decking, garage doors, concrete coatings, paint, doors, windows, flooring, ceiling, countertops, wall coverings and tiles. Users can save their projects, email them to a friend, and request a home install from their local Home Hardware store.</p>
<p><a href="http://www.homehardware.ca/index/renoworks-homeworks"><img src="http://www.flashdev.ca/wp-content/uploads/2010/01/Screen-shot-2010-01-15-at-10.32.24-AM-611x363.png" alt="" title="HomeWorks Home Remodelling Application" width="611" height="363" class="alignnone size-medium wp-image-225" /></a></p>
<p>You can use the HomeWorks Visualizer here: <a href="http://www.homehardware.ca/index/renoworks-homeworks">http://www.homehardware.ca/index/renoworks-homeworks</a></p>
<p>Your Scrapbook is a great place for members of the Home Hardware site to store photos they find inspirational into their very own scrapbook. Using the Image Grabber utility, which can be launched on any website using a bookmark, a member can add photos on the fly while they are surfing any web site.</p>
<p><a href="http://www.homehardware.ca/index/renoworks-scrapbook"><img src="http://www.flashdev.ca/wp-content/uploads/2010/01/Screen-shot-2010-01-15-at-10.27.52-AM-611x406.png" alt="" title="Your Scrapbook" width="611" height="406" class="alignnone size-medium wp-image-226" /></a></p>
<p>You can use Your Scrapbook here: <a href="http://www.homehardware.ca/index/renoworks-scrapbook">http://www.homehardware.ca/index/renoworks-scrapbook</a><br />
Note: You will need to register on the Home Hardware site before you can use the Scrapbook.</p>
<p>We developed the HomeWorks Visualizer &#038; Your Scrapbook using Adobe Flex, Java and db4o. We developed the Image Grabber using JSP, JavaScript &#038; HTML. Congratulations to everyone at RenoWorks for bringing this project to life.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/home-hardware-design-centre-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beauti-Tone Paint Home Designer Launched</title>
		<link>http://www.flashdev.ca/article/beauti-tone-paint-home-designer-launched/</link>
		<comments>http://www.flashdev.ca/article/beauti-tone-paint-home-designer-launched/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 16:34:09 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Beauti-Tone]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Home Hardware]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Launch]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=200</guid>
		<description><![CDATA[Home Hardware recently launched the Beauti-Tone Paint Home Designer. You can now customize the look of dozens of stock photographs using Beauti-Tone&#8217;s large selection of paint swatches and coordinated paint palettes. Users have the ability to save their projects, email their projects to a friend, calculate the amount of paint they will need, save their [...]]]></description>
			<content:encoded><![CDATA[<p>Home Hardware recently launched the Beauti-Tone Paint Home Designer. You can now customize the look of dozens of stock photographs using Beauti-Tone&#8217;s large selection of paint swatches and coordinated paint palettes. Users have the ability to save their projects, email their projects to a friend, calculate the amount of paint they will need, save their favourite paint swatches, and even print their completed project.</p>
<p><a href="http://www.homehardware.ca/index/renoworks" target="_blank"><img src="http://www.flashdev.ca/wp-content/uploads/2009/06/019-611x458.jpg" alt="Beauti-Tone Paint Home Designer" title="Beauti-Tone Paint Home Designer" width="611" height="458" class="alignnone size-full wp-image-201" /></a></p>
<p>Home Hardware also launched the Beauti-Tone Paint Colour Finder. This desktop application allows users to drag an eyedropper over any image on their computer and find the nearest matching Beauti-Tone colour.</p>
<p><a href="http://www.homehardware.ca/index/renoworks-colour-finder" target="_blank"><img src="http://www.flashdev.ca/wp-content/uploads/2009/06/002-611x458.jpg" alt="Beauti-Tone Colour Picker" title="Beauti-Tone Colour Picker" width="611" height="458" class="alignnone size-full wp-image-202" /></a></p>
<p>We developed the Home Designer using Adobe Flex, Java and db4o. We developed the Colour Picker using Java. Congratulations to everyone at RenoWorks for bringing this project to life.</p>
<p>You can try these applications out for yourself at <a href="http://www.homehardware.ca/index/renoworks" target="_blank">http://www.homehardware.ca/index/renoworks</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/beauti-tone-paint-home-designer-launched/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ArtPad: A Collection. A Connection</title>
		<link>http://www.flashdev.ca/article/artpad/</link>
		<comments>http://www.flashdev.ca/article/artpad/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 21:02:37 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Calgary]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Launch]]></category>
		<category><![CDATA[Rare Method]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=83</guid>
		<description><![CDATA[While working at Rare Method our team invested a lot of effort into designing and developing this great interactive Flash and HTML/CSS hybrid site. ArtPad was commissioned by the Calgary Glenbow Museum for the purpose of informing and interesting youth in contemporary art. I&#8217;m not sure when this site finally went live, but chances are [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.glenbow.org/artpad" target="_blank"><img src="http://www.flashdev.ca/wp-content/uploads/2008/11/picture-3-15-12-08-611x426.png" alt="ArtPad" title="artpad"  width="611" height="426" class="alignnone size-medium wp-image-94" /></a></p>
<p>While working at Rare Method our team invested a lot of effort into designing and developing this great interactive Flash and HTML/CSS hybrid site. ArtPad was commissioned by the Calgary Glenbow Museum for the purpose of informing and interesting youth in contemporary art. I&#8217;m not sure when this site finally went live, but chances are that you have never seen or even heard about it, as I was unable to find a press release or news article anywhere. Take a few minutes to check it out. I think you will enjoy it and maybe learn a thing or two about contemporary art.</p>
<p><a href="http://www.glenbow.org/artpad" target="_blank" >http://www.glenbow.org/artpad</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/artpad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 3 Cookbook Review</title>
		<link>http://www.flashdev.ca/article/flex-3-cookbook-review/</link>
		<comments>http://www.flashdev.ca/article/flex-3-cookbook-review/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 05:36:54 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=62</guid>
		<description><![CDATA[I just finished skimming through this book and have decided that every Flex developer should own a copy. I have been developing Flex applications for over a year now and I still managed to learn a ton of new things from this book. The authors have done an excellent job of formatting the book into [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oreilly.com/catalog/9780596529857/?CMP=ILC-search_spot1&#038;ATT=FLEX_Flex3Cookbook"><img src="http://www.flashdev.ca/wp-content/uploads/2008/09/9780596529857_cat1.gif" alt="" title="9780596529857_cat1" width="180" height="236" class="alignnone size-medium wp-image-63" /></a></p>
<p>I just finished skimming through this book and have decided that every Flex developer should own a copy. I have been developing Flex applications for over a year now and I still managed to learn a ton of new things from this book. The authors have done an excellent job of formatting the book into problem and solution scenarios. Quick and easy answers. The book starts off with issues a Flex noob might encounter and then proceeds all the way up to issues a Flex pro might encounter. Each solution includes code and a discussion/explination. This book is not really a cover to cover read,  but more of a quick reference that you want to have within an arms reach while coding. I still recommend skimming through it when you first get it, because I&#8217;m sure you&#8217;ll learn a bunch of new tidbits right off the bat.</p>
<p>You can get more info and purchase this book <a href="http://oreilly.com/catalog/9780596529857/?CMP=ILC-search_spot1&#038;ATT=FLEX_Flex3Cookbook">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/flex-3-cookbook-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercedes-Benz USA Launches Website Redesign</title>
		<link>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/</link>
		<comments>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 17:54:02 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Critical Mass]]></category>
		<category><![CDATA[Mercedes-Benz]]></category>
		<category><![CDATA[Redesign]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/</guid>
		<description><![CDATA[Yesterday MBUSA.com launched their website redesign. The new site is a major face lift from the old version, which was beginning to look outdated in comparison to many of its competitors. Every single element of the site has been upgraded and built completely in Flash, improving the overall user experience throughout. I worked on the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="http://www.mbusa.com/" target="_blank">MBUSA.com</a> launched their website redesign. The new site is a major face lift from the old version, which was beginning to look outdated in comparison to many of its competitors. Every single element of the site has been upgraded and built completely in Flash, improving the overall user experience throughout.</p>
<p><a href="http://www.mbusa.com/" target="_blank"><img src="http://www.flashdev.ca/wp-content/uploads/2008/07/mbusa.jpg" alt="Screen shot of the new MBUSA site" border="0" /></a></p>
<p>I worked on the initial stages of this redesign at <a href="http://www.criticalmass.com/" target="_blank">Critical Mass</a> over two years ago. My involvement at the time was building a working prototype of the site in Flash. Only a few vehicles could be selectable back then, but overall the site&#8217;s design has not changed too much. The Mercedes-Benz&#8217; development team has done a great job of finishing it off.</p>
<p>Congratulations to everyone involved in creating this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A must-read for learning ActionScript 3.0</title>
		<link>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/</link>
		<comments>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 17:34:33 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open-Source]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/</guid>
		<description><![CDATA[I just stumbled across a great article by Josh Tynjala on the Yahoo! Flash Developer Center. Josh writes about the new features of ActionScript 3.0, focusing on working with the Display List, changes to root and parent, and encapsulation. I&#8217;m sure this article has been around for some time, but if you are just getting [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across a great article by Josh Tynjala on the Yahoo! Flash Developer Center. Josh writes about the new features of ActionScript 3.0, focusing on working with the Display List, changes to root and parent, and encapsulation. I&#8217;m sure this article has been around for some time, but if you are just getting into AS3 and have not yet seen this article, then I highly recommend you read it.</p>
<p><a href="http://developer.yahoo.com/flash/articles/display-list.html">http://developer.yahoo.com/flash/articles/display-list.html</a></p>
<p>The Yahoo! Flash Developer Center also has some great open-source components available for download. I am playing around with the Charts and I am very impressed. These seem like a great and free alternative to <a href="http://www.fusioncharts.com/">FusionCharts</a>, which at this time are not available for ActionScript 3.0.</p>
<p>Here are some examples of the Yahoo! ASTRA Charts:<br />
<a href="http://developer.yahoo.com/flash/astra-flash/charts/examples.html">http://developer.yahoo.com/flash/astra-flash/charts/examples.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Loading and Saving External XML Data in AIR (Apollo)</title>
		<link>http://www.flashdev.ca/article/loading-and-saving-xml-data-in-air-apollo/</link>
		<comments>http://www.flashdev.ca/article/loading-and-saving-xml-data-in-air-apollo/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 22:59:31 +0000</pubDate>
		<dc:creator>fraser.crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[AIR (Apollo) Tutorial]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Apollo]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/loading-and-saving-xml-data-in-air-apollo/</guid>
		<description><![CDATA[I just finished an AIR (Apollo) application that loads and saves data from an external XML file. I figured I would share the code to accomplish this task as there is not a lot of Apollo info around at this time. First off lets start with loading an XML file and reading its contents. I [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished an AIR (Apollo) application that loads and saves data from an external XML file. I figured I would share the code to accomplish this task as there is not a lot of Apollo info around at this time.</p>
<p>First off lets start with loading an XML file and reading its contents. I realize that there are much easier ways to load XML into Flash than this, but the advantage here is that I can use <em>File.applicationResourceDirectory</em> which allows me to target the installation directory for the XML file that was included with the AIR package. In this snippet I am using the synchronous open method.  This essentially pauses everything else in the Flash movie until it has completed its task (opening the file).</p>
<p><span id="more-47"></span></p>
<pre>
<code>
import flash.filesystem.*;

private var _data:String; // Data string pulled from the xml file.

/**
 * Load the xml file and read its data.
 */
private function loadData():void
{
  var dataFile:File = File.applicationResourceDirectory.resolve("data.xml");
  var stream:FileStream = new FileStream();
  stream.open(dataFile, FileMode.READ);
  _data = stream.readUTFBytes(stream.bytesAvailable);
  stream.close();
}
</code>
</pre>
<p>This next snippet shows how to save data to a file using the asynchronous openAsync method. The asynchronous methods allow Flash to continue running normally and use events to trigger user specified actions.</p>
<pre>
<code>
private var _dataXML:XML;	// The XML data.

/**
 * Save the modified data to the xml file.
 */
private function saveData():void
{
  var dataFile:File = File.applicationResourceDirectory.resolve("data.xml");
  var stream:FileStream = new FileStream();
  stream.openAsync(dataFile, FileMode.WRITE);
  stream.writeUTFBytes(_dataXML);
  stream.addEventListener(Event.CLOSE, onDataSaved);
  stream.close();
}

/**
 * Called when the data has been successfully saved.
 * Load the saved data back into the application.
 */
private function onDataSaved(event:Event):void
{
  loadData();
}
</code>
</pre>
<p>If you are planning on using AIR (Apollo) for your own projects I would highly recommend reading <a href="http://download.macromedia.com/pub/labs/apollo/documentation/apollo_for_flex_pocketguide_031907.pdf">Apollo for Adobe Flex Developers Pocket Guide</a> by Mike Chambers, Robert L. Dixon &#038; Jeff Swartz.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/loading-and-saving-xml-data-in-air-apollo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.755 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-18 09:49:04 -->

