<?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>Pixelbox &#187; AIR</title>
	<atom:link href="http://www.pixelbox.net/category/development/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pixelbox.net</link>
	<description>Pixelbox, technology development and photography.</description>
	<lastBuildDate>Thu, 08 Apr 2010 16:35:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Caching gotcha in AIR</title>
		<link>http://www.pixelbox.net/2009/10/02/caching-gotcha-in-air/</link>
		<comments>http://www.pixelbox.net/2009/10/02/caching-gotcha-in-air/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 13:38:30 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/?p=379</guid>
		<description><![CDATA[Every had a problem with Adobe AIR caching your HTTP requests? Read on...]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a problem in AIR, where my application wasn&#8217;t updating content it was getting from an HTTP request even though the page had changed.</p>
<p>I was able to use <a href="http://www.charlesproxy.com/">Charles Proxy</a> to see that the application wasn&#8217;t even making the requests to the server, meaning it must be an issue with AIR rather than local or remote DNS, or web servers.</p>
<p>My requests were being made by the HTTPService class, and I couldn&#8217;t find any properties of methods that where related to caching, however I did find that URLRequest had two properties, useCache and cacheResponce.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> urlRequest<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = _new <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
urlRequest.cacheResponse = <span style="color: #0033ff; font-weight: bold;">false</span>;
urlRequest.useCache = <span style="color: #0033ff; font-weight: bold;">false</span>;</pre></div></div>

<p>
This is quite handy, although it didn&#8217;t seem to work for me, and also wasn&#8217;t idea for the situation I was in. After doing some digging on the web I found the classic solution of adding a random number to the end of the URL
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
&nbsp;
&nbsp;
 <span style="color: #6699cc; font-weight: bold;">var</span> urlRequest<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = _new <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'http://www.example.com/'</span><span style="color: #000000;">&#41;</span>;
 urlRequest.<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'?nocache='</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">100</span>;</pre></div></div>

<p>
Again this isn&#8217;t ideal and could lead to problems, especially if you don&#8217;t know what server or URL the requests may be sent for. There is a chance the nocache (or any) variable could cause problems.
</p>
<p>
Eventually I noticed that the URLRequest&#8217;s cacheResponse entry on livedocs had a &#8220;See also&#8221; pointing to <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequestDefaults.html#cacheResponse">flash.net.URLRequestDefaults.cacheResponse</a>. This solved all my problems, and is essentially a default for all URL requests made my AIR.
</p>
<p>
The properties appear to be static variables so you can set them like so:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">// Turn caching off for AIR</span>
URLRequestDefaults.cacheResponse = <span style="color: #0033ff; font-weight: bold;">false</span>;
URLRequestDefaults.useCache = <span style="color: #0033ff; font-weight: bold;">false</span>;</pre></td></tr></table></div>

<p>
This only needs to be done once, so you can add it to your applications start up cycle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2009/10/02/caching-gotcha-in-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extended AIR App Updater</title>
		<link>http://www.pixelbox.net/2009/09/02/extended-air-app-updater/</link>
		<comments>http://www.pixelbox.net/2009/09/02/extended-air-app-updater/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:13:11 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/?p=347</guid>
		<description><![CDATA[Ever wished there was a way to force app updates using the ApplicationUpdaterUI? Now there is.]]></description>
			<content:encoded><![CDATA[<p>I have always used Adobe&#8217;s <a href="http://www.adobe.com/devnet/flex/tourdeflex/langref/air/update/ApplicationUpdaterUI.html">ApplicationUpdater</a> in my AIR apps, either with or without the UI. However every time I do I always find I need the functionality to force the user to update. This is normally due to an important feature or bug fix that I need pushed out to users, or just to make sure those users who never update don&#8217;t get too far behind (I recently found my dad had never updated any of his iPhone apps).
</p>
<p><div id="attachment_360" class="wp-caption alignnone" style="width: 310px"><img src="http://www.pixelbox.net/wp-content/uploads/2009/09/Picture-2-300x149.png" alt="Update framework" title="Update" width="300" height="149" class="size-medium wp-image-360" /><p class="wp-caption-text">Update framework</p></div>
<p>
When using the ApplicationUpdater (without the UI), you can easily force the install of all updates, but this isn&#8217;t very user friendly, and not a great experience. Often it&#8217;s far too time consuming to write your own UI for the update framework, so ideally I wanted to create a way of supporting required updates whilst using the existing UI as much as possible.
</p>
<p>
In order to do this I wrote a decorator for the ApplicationUpdaterUI which added the new event RequiredStatusUpdateEvent. This is dispatched when the updateDescriptor file is downloaded and includes the value of a new node called required (which you need to add to your update.xml file):
</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;update</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/air/framework/update/description/1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.pixelbox.net/demos/extendedAppUpdater/ExampleAirApp-2.air<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		Version 2
		- Lots of great new features
		- Required security patch
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;required<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/required<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/update<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><small>The text &#8220;true&#8221; will translate into a Boolean set to true, anything else will be false.</small></p>
</p>
<p>
You can then add a listener for the  (along with any default events), to tell your user they have to update to the new required version. This can be as simple as:
</p>

<div class="wp_syntax"><div class="code"><pre class="applicationscript3" style="font-family:monospace;">&nbsp;
           private function onUpdate(event:RequiredStatusUpdateEvent):void
            {
                if (event.required &amp;&amp; event.available)
                    // Required update available 
                else
                    // There isn't a required update, so leave it up to the ApplicationUpdaterUI
            }</pre></div></div>

<p>
From a UX point of view this works rather well. You can choose how your application responds to a required update, and don&#8217;t need to force the install in the background and restart the app. I like to change the state of the app, as well as letting the ApplicationUpdaterUI window open. If the user upgrades through the default UI, great, if not they will be presented with a new app state, telling them there is a required update, perhaps even why it&#8217;s important. You may even want to let them do some things but not others (such as letting them save their work, or finishing their current workflow). Either way it gives your app the choice of how it wants to behave.
</p>
<p>I have created a little example app (with view source enabled) that uses the this code, as well as a .swc and the example app as a project.</p>
<ul>
<li><a href="http://www.pixelbox.net/demos/extendedAppUpdater/ExampleAirApp-1.air">Example AIR Application</a></li>
<li><a href="http://www.pixelbox.net/demos/extendedAppUpdater/ExtendedAppUpdater.swc">Extended Updater swc file</a></li>
<li><a href="http://www.pixelbox.net/demos/extendedAppUpdater/ExampleAirApp.zip"> Example Air App project</a></li>
<li><a href="http://www.pixelbox.net/demos/extendedAppUpdater/update.xml"> Example update descriptor XML file</a></li>
</ul>
<p>If you install the above air file, you will be able to check for updates and receive a required update. When this happens the app&#8217;s main function is disabled and a message displayed telling the user to upgrade.</p>
<p>Please let me know if you have any questions, or would like to add to this little framework, good luck. If you want to create your own without using the default UI check out <a href="http://www.blackpepper.co.uk/black-pepper-blog/Example-auto-updating-AIR-desktop-app.html">this article on Black Pepper</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2009/09/02/extended-air-app-updater/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Detecting if running in ADL</title>
		<link>http://www.pixelbox.net/2009/07/07/detecting-if-running-in-adl/</link>
		<comments>http://www.pixelbox.net/2009/07/07/detecting-if-running-in-adl/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 14:39:11 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/?p=317</guid>
		<description><![CDATA[A quick example of how to tell when an AIR application is running in debug mode. Allowing you to stop costly tasks when doing so.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-318" title="adl" src="http://www.pixelbox.net/wp-content/uploads/2009/07/adl.png" alt="" width="160" height="108" /></p>
<p><strong><br />
NOTE: I have since discovered the Capabilities class that has a boolean called isDebugger. Therefore you can do this like so:</strong>
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">Capabilities</span>.<span style="color: #004993;">isDebugger</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'This app is running in the ADL'</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Original post:</strong></p>
<p>I recently came across the situation where I wanted to detect if my AIR application was running, &#8220;for real&#8221; or running in debug mode (in the Adobe Debug Launcher ADL).</p>
<p>With a standard Flex &gt; SWF project you can change the HTML of the debug template to pass through a debug=true variable. However with an AIR project you don&#8217;t have this luxury.</p>
<p>The reason I want to do this, is I don&#8217;t want some things to happen when I&#8217;m debugging (such as sending stats to the server) and I don&#8217;t want to have custom variables or comment out code incase I forget to turn them back on before pushing live. By having a way of checking if the app is running in the ADL you can optionally stop things, safe in the knowledge that when they go live they will work.</p>
<p>I searched the web to see if there was a way to tell if AIR was running in debug mode, or in the ADL or was even a release build, but I couldn&#8217;t find a specific API call. What I did find is a number of methods that only worked if running in the ADL. All I had to do then was find one that returned different values depending on that fact. The Error class has a method getStackTrace() that return null if not running in the ADL and a string if it is, this was perfect and can be used like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">getStackTrace</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'This app is running in the ADL'</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This code isn&#8217;t perfect, in the future the getStackTrace method could start working when not running in the ADL. You could also combine a few ADL specific methods, for better piece of mind. If you know of a better solution please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2009/07/07/detecting-if-running-in-adl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract files in AS3 (AIR)</title>
		<link>http://www.pixelbox.net/2008/10/16/extract-files-in-as3-air/</link>
		<comments>http://www.pixelbox.net/2008/10/16/extract-files-in-as3-air/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 15:01:18 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/?p=309</guid>
		<description><![CDATA[A little code snippet, to extract an array of files from folder(s) in AIR.]]></description>
			<content:encoded><![CDATA[<p>
I am currently working on a client side application written in AIR. I need to allow the user to drag a list of files onto the application and then validate them checking for file type and size.
</p>
<p>
I hit a problem with the user dragging folders, as they are handled as a file with a property of directory. In order to iterate through an array of these files and folders I needed a way to turn an array of files and folders into an array of just the files.
</p>
<p>
In the following function you can pass it an array of files and it will flatten it, but returning an array of just the files. It also removes hidden files!
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">		<span style="color: #3f5fbf;">/**
		 * This function takes an array of files and folders and retuns an array of just files
		 * This function also removes hidden files
		 * @param files
		 * 
		 */</span>		
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> _cleanFileArray<span style="color: #000000;">&#40;</span> files <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> arrayToReturn <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> fileOrDir <span style="color: #000000; font-weight: bold;">:</span> File <span style="color: #0033ff; font-weight: bold;">in</span> files <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> fileOrDir.isDirectory <span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// If we find a directory, call this method again to extract the files</span>
					<span style="color: #009900;">// This will recurse until there are only files in the returning array</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> subArray <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> =  <span style="color: #0033ff; font-weight: bold;">this</span>._cleanFileArray<span style="color: #000000;">&#40;</span> fileOrDir.getDirectoryListing<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
					arrayToReturn = arrayToReturn.<span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span> subArray <span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// Combin the files with the arrayToReturn</span>
				<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> fileOrDir.isHidden <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// Skip hidden files</span>
				<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// If we have a file add it to the array of files to return</span>
					arrayToReturn.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span> fileOrDir <span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> arrayToReturn;
		<span style="color: #000000;">&#125;</span></pre></div></div>

<p>
You could turn this into a static function on a helper class if you want. Tags: Removing folders from file list, extracting files from folders, flattening folders, removing hidden folders.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2008/10/16/extract-files-in-as3-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Binding to private vars in Flex</title>
		<link>http://www.pixelbox.net/2008/04/24/binding-to-private-vars-in-flex/</link>
		<comments>http://www.pixelbox.net/2008/04/24/binding-to-private-vars-in-flex/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 16:21:08 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/?p=270</guid>
		<description><![CDATA[Using Bindable variables and properties in Flex (Action Script 3) is great, it saves a huge amount of time adding events left right and center. However today I had a problem where I wanted to use a setter for a variable. In order to do this I made it private and used a getter and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.pixelbox.net/wp-content/uploads/2008/04/flex3_fx_124x120.jpg" alt="The Flex Logo" title="Flex3" width="85" height="85" class="alignnone size-full wp-image-269" /></p>
<p>
Using Bindable variables and properties in Flex (Action Script 3) is great, it saves a huge amount of time adding events left right and center. However today I had a problem where I wanted to use a setter for a variable. In order to do this I made it private and used a getter and setter function, allowing me to add some logic when setting the variable.
</p>
<p>
The problem however is that private variables are unbindable. You will get a warning on anything bound to it, saying it will not see changes. There is a very simple way to get around this, but making the getters and setters bindable.
</p>
<p><pre><code>
[Bindable]
public function set yourVar ( s : String ):void
{
//Some logic can go here
_yourVar = s;
}

public function get yourVar ( ):String
{
// Some logic perhaps
return _yourVar;
}
</code></pre>
<pre>
</pre>
</p>
<p>
By putting the [Bindable] tag before the function (I assume you only need it above one), any variables bound to <strong>yourVar</strong> will work. You don&#8217;t need a [Bindable] before your declaration of the private _yourVar and you should use yourClassInstance.yourVar when binding, rather than _yourVar.
</p>
<p>
Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2008/04/24/binding-to-private-vars-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the default loading screen in Flex</title>
		<link>http://www.pixelbox.net/2008/03/13/changing-the-default-loading-screen-in-flex/</link>
		<comments>http://www.pixelbox.net/2008/03/13/changing-the-default-loading-screen-in-flex/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 12:49:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/2008/03/13/changing-the-default-loading-screen-in-flex/</guid>
		<description><![CDATA[One of the first things you want to do when creating a Flex app is to remove all the default stuff, which makes your app look like everyone else&#8217;s. The most obvious default thing in Flex is that loading, progress initilisation bar you get before the application starts. Now before I start there is one [...]]]></description>
			<content:encoded><![CDATA[<p>
One of the first things you want to do when creating a Flex app is to remove all the default stuff, which makes your app look like everyone else&#8217;s. The most obvious default thing in Flex is that loading, progress initilisation bar you get before the application starts.
</p>
<p>
Now before I start there is one thing to look out for. I first wanted to change the background colour, and kept getting a flash of that Windows 98 turquoise before it change to my new colour&#8230; This had me really confused for a while, until I realised that the auto generated HTML that Flex Builder 3 creates has that same colour as it&#8217;s default background&#8230; Doh! (You can also get the compiler to change this, see the <a href="http://www.gotoandlearn.com/play?id=108">gotoAndLearn example</a> for more info)
</p>
<p>
Quite a few of the settings of the loading screen can be set through the mx:Application tag, in your Application Class&#8217;s MXML. The most obvious being the background colour. This is also where you can specify your own download screen, or as Adobe call it, &#8220;DownloadProgressBar&#8221;.
</p>
<p>
At the highest level a Flex application is a two frame movie clip, the first frame being the aforementioned, &#8220;DownloadProgressBar&#8221; and the second being your Application class. In order to draw images and a progress bar on your loading class thing, you will need to extend the Sprite class (like a movieclip without frames) and implement the IPreloaderDisplay. ( Holy object orientation Batman! Don&#8217;t worry you can just copy my example and ignore that if you want!)
</p>
<p>
When creating your own &#8220;DownloadProgressBar&#8221; you need to keep it lightweight, otherwise you will have to make a &#8220;DownloadProgressBar&#8221; for that! Also some elements of the Flex framework won&#8217;t be available when it starts, so don&#8217;t go too crazy!
</p>
<p>
The first step is to add this to the <mx :Application> tag in your Application&#8217;s MXML file<br />
</mx></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">preloader=<span style="color: #ff0000;">&quot;com.example.preloaders.myDownloadProgressBar&quot;</span></pre></div></div>

<p>
Once this is added your application will use your custom &#8220;DownloadProgressBar&#8221; Class, rather than the default one. This means you can do lots of stuff yourself with the information provided, such as total to download and total downloaded, in addition to some events called at various stages of initilisation.
</p>
<p>
<a href="http://www.pixelbox.net/demos/downloadProgressBar/MyDownloadProgressBar.as" title="Download example of my Download Progress Bar">Download the Download Progress Bar example class here</a>. I have commented as much as I can, and will try and put a demo together soon.</p>
<p />
<p>
Other examples:</p>
<ul>
<li>http://www.onflex.org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.php</li>
<li>http://flexiblemyself.blogspot.com/2007/10/custom-preloader.html</li>
<li>http://iamjosh.wordpress.com/2007/12/18/flex-custom-preloader/</li>
<li>https://defiantmouse.com/yetanotherforum.net/default.aspx?g=posts&#038;t=82</li>
<li>http://www.gotoandlearn.com/play?id=108</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2008/03/13/changing-the-default-loading-screen-in-flex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Caculating Dates in AS3</title>
		<link>http://www.pixelbox.net/2007/09/27/caculating-dates-in-as3/</link>
		<comments>http://www.pixelbox.net/2007/09/27/caculating-dates-in-as3/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 15:07:07 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/2007/09/27/caculating-dates-in-as3/</guid>
		<description><![CDATA[ ]]></description>
			<content:encoded><![CDATA[<p>
Here is a little example of how to return a date a set number of days from any given date in ActionScript 3 (Flex, AIR).
</p>
<p>
I used the example to return a set number of days since one of our issues launched, by sending the function the number of days and the starting date.
</p>
<p><pre>
<code>
/* This is a public static function so it can be called from my
utility class of useful converts and such! */

public static function returnDateXDaysFromY( x:Number , y:Date ):Date
{
  var xDaysFromY:Date = new Date(); // Date to return
  // I have removed a call to a function to set the time to zero, you can get caught out with summer time etc
  x = ((((x * 24)* 60) * 60) * 1000); // Turn days to miliseconds
  xDaysFromY.setTime( x + y.getTime() );
  return xDaysFromY;
}

</code>
</pre>
</p>
<p>
Hopefully someone else out there will find this handy :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2007/09/27/caculating-dates-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date conversions in AS3</title>
		<link>http://www.pixelbox.net/2007/07/24/date-conversions-in-as3/</link>
		<comments>http://www.pixelbox.net/2007/07/24/date-conversions-in-as3/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 16:49:29 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/2007/07/24/date-conversions-in-as3/</guid>
		<description><![CDATA[I have been re factoring some stuff in action script 3 recently and the old date manipulation was a bit hacky. It included get time then adding multiples of milliseconds to epocs, which was a bit confusing. I though I would be a good idea to write a few methods in my personal utilities class, [...]]]></description>
			<content:encoded><![CDATA[<p>
I have been re factoring some stuff in action script 3 recently and the old date manipulation was a bit hacky. It included get time then adding multiples of milliseconds to epocs, which was a bit confusing.
</p>
<p>
I though I would be a good idea to write a few methods in my personal utilities class, simple stuff like returning yesterday, tomorrow or this time next week etc. After a bit of research I found that some time constants have already been defined in the Action Script 3.0 cookbook utils. If you don&#8217;t have it then these are the constants for various amounts of time.
</p>
<pre>
<code>
	public static const MILLISECOND:Number = 1;
	public static const SECOND:Number = MILLISECOND * 1000;
	public static const MINUTE:Number = SECOND * 60;
	public static const HOUR:Number = MINUTE * 60;
	public static const DAY:Number = HOUR * 24;
	public static const WEEK:Number = DAY * 7;
</code>
</pre>
<p>
With these handy chaps you can easily get a date variable for yesterday or tomorrow or in 7 days:
</p>
<pre>
<code>
	//Replace DateUtilities. with this. if you are including them in your own class

	var yesterday:Date = new Date();
	yesterday.time -= DateUtilities.DAY;

	var tomorrow:Date = new Date();
	tomorrow.time += DateUtilities.DAY;

	var weekToday:Date = new Date();
	weekToday.time += DateUtilities.WEEK;
</code>
</pre>
<p>
Neat hu!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2007/07/24/date-conversions-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apollo is dead, long live AIR!</title>
		<link>http://www.pixelbox.net/2007/06/11/apollo-is-dead-long-live-air/</link>
		<comments>http://www.pixelbox.net/2007/06/11/apollo-is-dead-long-live-air/#comments</comments>
		<pubDate>Mon, 11 Jun 2007 07:23:47 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/2007/06/11/apollo-is-dead-long-live-air/</guid>
		<description><![CDATA[In a rather large step backwards in marketing and buzz word&#8230; well, buzzing, Adobe have changed the name of Apollo (their code name) to Adobe Integrated Runtime or AIR. I guess you could have seen this coming as the .air extension has been used for the install files since day one, although I thought Apollo [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://labs.adobe.com/technologies/air/images/adobe_air.gif" height="64" width="156" /></p>
<p>In a rather large step backwards in marketing and buzz word&#8230; well, buzzing, Adobe have changed the name of Apollo (their code name) to Adobe Integrated Runtime or AIR.</p>
<p>I guess you could have seen this coming as the .air extension has been used for the install files since day one, although I thought Apollo was kind of cool.</p>
<p>To find out more check out the <a href="http://labs.adobe.com/technologies/air/">AIR info page</a> and see what sorts of demo <a href="http://labs.adobe.com/showcase/air/">launch applications they have</a>. The thing that is going to annoy me now though is people saying Adobe AIR, as Adobe will be repeated twice&#8230; but hey!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2007/06/11/apollo-is-dead-long-live-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adobe Live</title>
		<link>http://www.pixelbox.net/2007/06/06/adobe-live/</link>
		<comments>http://www.pixelbox.net/2007/06/06/adobe-live/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 23:06:09 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.pixelbox.net/2007/06/06/adobe-live/</guid>
		<description><![CDATA[The evening we popped down to Adobe live to be confronted with the normal (and expected) sales stuff, in fact there seemed to be almost as many people there from Adobe as visitors! After buying some books (more on them later) and .net magazine (again more on that later) we made a quick exit and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/robmcm/532384223/" title="Photo Sharing"><img src="http://farm2.static.flickr.com/1374/532384223_5a38fc8cb1_m.jpg" width="240" height="77" alt="main_banner" /></a><br />
The evening we popped down to Adobe live to be confronted with the normal (and expected) sales stuff, in fact there seemed to be almost as many people there from Adobe as visitors!</p>
<p>After buying some books (more on them later) and <a href="http://http://www.netmag.co.uk/" title="Dot net magazine">.net</a> magazine (again more on that later) we made a quick exit and cursed the fact we couldn&#8217;t get tickets for the, &#8220;sold out&#8221; development evening.</p>
<p>By chance one of the organizers from the event popped into our offices to check out <a href="http://www.cerosmedia.com/" title="Who needs paper?">Ceros</a> and Tom managed to ask him to get us on the guest list for the evenings event, result!</p>
<p>To be honest I didn&#8217;t know what to expect, and apart from <a href="http://aralbalkan.com/" title="God of gods aparently">Aral</a> I knew very little about the speakers. The discussion was chaired by                   <a href="http://www.flashonthebeach.com/" title="This guy flashes on the beach!">John Davey</a> who did a fantastic job, both entertaining and netural, dispite there only being about 30 people who actualy turned up, lucky we got in! The talk centered around Open Source, and what it really meant. Although discussion often focused on how it&#8217;s a viable thing to do, why do it, why care as a user, and various other discussions that will never be answered in my mini review at 11:52 at night&#8230; or in fact ever!</p>
<p>I was lucky enough to have a long talk with <a href="http://blogs.adobe.com/open/">                   David McAllister</a>, Director of Standards and Open Source, at Adobe, after the formal discussions had ended (he was in the room when the term Open Source was coined!!!) which was fascinating, and to be honest left me feeling a little inadequate.</p>
<p>It was also great to catch up with Aral and meet <a href="http://blog.noventaynueve.com/">Carlos Ulloa</a> and <a href="http://www.tink.ws/blog/">Tink</a>, oh and also get some free food, drinks&#8230; and a bag ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelbox.net/2007/06/06/adobe-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
