<?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>Nick Kuh - Freelance iPhone, iPad, iOS Developer, Trainer and Consultant - Brighton, UK &#187; Examples</title>
	<atom:link href="http://www.nickkuh.com/category/flash-flex-air/examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nickkuh.com</link>
	<description>Nick Kuh is a Freelance iPhone, iPad, iOS Developer, Trainer and Consultant based in Brighton, UK</description>
	<lastBuildDate>Thu, 10 Nov 2011 20:40:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>How to make a custom Flash Preloader for a Flex Application</title>
		<link>http://www.nickkuh.com/flash-flex-air/how-to-make-a-custom-flash-preloader-for-a-flex-application/2009/03/</link>
		<comments>http://www.nickkuh.com/flash-flex-air/how-to-make-a-custom-flash-preloader-for-a-flex-application/2009/03/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 11:32:30 +0000</pubDate>
		<dc:creator>Nick Kuh</dc:creator>
				<category><![CDATA[Adobe Flash, Flex and Air]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Preloader]]></category>

		<guid isPermaLink="false">http://www.nickkuh.com/?p=137</guid>
		<description><![CDATA[There are a number of useful Flex techniques I use in the Flex Apps I develop all the time and I thought that some of these might be useful for others. So here&#8217;s the first&#8230; How to replace that nasty default Flex preloader with your own Flash animated version. Here&#8217;s the result (I just downloaded [...]]]></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.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;source=nickkuh&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>There are a number of useful Flex techniques I use in the Flex Apps I develop all the time and I thought that some of these might be useful for others. So here&#8217;s the first&#8230; How to replace that nasty default Flex preloader with your own Flash animated version. Here&#8217;s the result (I just downloaded a free preloader animation from the web and applied it to this tutorial:</p>
<p><a href="http://www.nickkuh.com/demos/custom_preloader/">http://www.nickkuh.com/demos/custom_preloader/</a></p>
<p>Flex source files can be downloaded from here:</p>
<p><a href="http://www.nickkuh.com/demos/custom_preloader/srcview/CustomPreloader.zip">http://www.nickkuh.com/demos/custom_preloader/srcview/CustomPreloader.zip</a></p>
<p>How it works:</p>
<p>Inside the main application MXML you can specify a custom preloader class for your application to use:</p>
<blockquote><p>&lt;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221;<br />
layout=&#8221;vertical&#8221;<br />
backgroundColor=&#8221;#000000&#8243;<br />
backgroundGradientAlphas=&#8221;[0.0,0.0]&#8220;<br />
paddingTop=&#8221;30&#8243;<br />
applicationComplete=&#8221;init()&#8221;<br />
preloader=&#8221;com.nickkuh.preload.Preloader&#8221;  viewSourceURL=&#8221;srcview/index.html&#8221;&gt;</p></blockquote>
<p>So you&#8217;ll see I&#8217;m pointing the preloader to my com.nickkuh.preload.Preloader class. This class extends the default Flex DownloadProgressBar class: mx.preloaders.DownloadProgressBar. The Flex Framework passes the application it&#8217;s loading to preloader setter method which I&#8217;m overriding:</p>
<blockquote><p>override public function set preloader(value:Sprite):void{<br />
value.addEventListener(ProgressEvent.PROGRESS, progressEventHandler, false, 0, true);<br />
value.addEventListener(Event.COMPLETE, completeEventHandler, false, 0, true);<br />
value.addEventListener(FlexEvent.INIT_PROGRESS, initProgressEventHandler, false, 0, true);<br />
value.addEventListener(FlexEvent.INIT_COMPLETE, initCompleteEventHandler, false, 0, true);<br />
}</p></blockquote>
<p>So my custom Preloader class is now able to listen to the application preloading events &#8211; halfway there&#8230;</p>
<p>In the constructor for the Preloader class I&#8217;m creating an instance of another custom class which deals with displaying the Flash loading animation and adding this instance to the stage:</p>
<blockquote><p>progressBar = new ProgressBar;<br />
this.addChild(progressBar);</p></blockquote>
<p>The Preloader class listens to the instance of the com.nickkuh.preload.ProgressBar class for the custom event ProgressBar.FADE_OUT_COMPLETE. Only when that event is fired will the Preloader class in turn fire an Event.COMPLETE event which the Flex app listens for before it displays the loaded application and fires the applicationComplete event. So this set-up enables the custom ProgressBar to control when the Flex app changes the view from preloader to application.</p>
<p>The custom ProgressBar class extends Flex&#8217;s Loader class and loads in the flash loading animation. I&#8217;ve set this up so that the ProgressBar checks for the path to the preloader.swf via FlashVars:</p>
<blockquote><p>var url:String;<br />
if (this.stage.loaderInfo.parameters.hasOwnProperty(&#8220;preloaderURL&#8221;))<br />
{<br />
url = this.stage.loaderInfo.parameters.preloaderURL;<br />
}<br />
else<br />
{<br />
url = &#8220;preloader.swf&#8221;;<br />
}<br />
var urlRequest:URLRequest = new URLRequest(url)<br />
this.load(urlRequest);</p></blockquote>
<p>You&#8217;ll find the fla for the preloader in the source files in a folder called &#8216;design&#8217;. The fla actually includes a couple of methods on frame one:</p>
<blockquote><p>stop();</p>
<p>function setProgress(n:Number)<br />
{</p>
<p>}</p>
<p>function set ready(b:Boolean)<br />
{<br />
if (b) gotoAndPlay(2);<br />
}</p></blockquote>
<p>The custom ProgressBar class calls these methods with progress updates and sets the ready setter to true when the Flex App has finished loading. If you&#8217;re loading animation is a progress bar or needs to give percentage feedback then you can customise the setProgress(n:Number) function &#8211; n will be between 0 and 1 &#8211; 1 for fully loaded.</p>
<p>In my fla once the preload completes it then plays a few more frames before fading out. This animation could be changed to you requirements.</p>
<p>Once the internal fade out complete the fla fires off an &#8220;animationComplete&#8221; event which the ProgressBar is listening out for. At this point the closeScreen method of ProgressBar handles the event and ProgressBar fades itself out. Once complete it in turn fires the FADE_OUT_COMPLETE event which causes the main Flex app to close the preloader and display your Flex App.</p>
<p>Yes, it&#8217;s a bit time consuming to make a simple preloader but I now use this set-up over and over again. Feel free to do the same!</p>
<ul class="socialwrap size32 row">
<li class="iconOnly"><a rel="nofollow" target="_blank" class="delicious" href="http://delicious.com/post?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;title=How+to+make+a+custom+Flash+Preloader+for+a+Flex+Application" title="Bookmark this post : How to make a custom Flash Preloader for a Flex Application on Delicious"><span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="digg" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;title=How+to+make+a+custom+Flash+Preloader+for+a+Flex+Application&amp;bodytext=There+are+a+number+of+useful+Flex+techniques+I+use+in+the+Flex+Apps+I+develop+all+the+time+and+I+thought+that+some+of+these+might+be+useful+for+others.+So+here%27s+the+first...+How+to+replace+that+nasty+default+Flex+preloader+with+your+own+Flash+animated+version.+Here%27s+the+result+%28I+just+downloaded+a+free+preloader+anim" title="Digg this post : How to make a custom Flash Preloader for a Flex Application"><span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="facebook" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;t=How+to+make+a+custom+Flash+Preloader+for+a+Flex+Application" title="Recommend this post : How to make a custom Flash Preloader for a Flex Application on Facebook"><span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="reddit" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;title=How+to+make+a+custom+Flash+Preloader+for+a+Flex+Application" title="Share this post : How to make a custom Flash Preloader for a Flex Application on Reddit"><span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="stumble" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F&amp;title=How+to+make+a+custom+Flash+Preloader+for+a+Flex+Application" title="Share this post : How to make a custom Flash Preloader for a Flex Application with Stumblers"><span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="twitter" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fhow-to-make-a-custom-flash-preloader-for-a-flex-application%2F2009%2F03%2F" title="Tweet this post : How to make a custom Flash Preloader for a Flex Application on Twitter"><span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="" class="rss" href="http://www.nickkuh.com/flash-flex-air/how-to-make-a-custom-flash-preloader-for-a-flex-application/2009/03/feed" title="Follow this post : How to make a custom Flash Preloader for a Flex Application comments"><span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nickkuh.com/flash-flex-air/how-to-make-a-custom-flash-preloader-for-a-flex-application/2009/03/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>New Flex/AIR component: keep track of your user&#8217;s Internet connection status</title>
		<link>http://www.nickkuh.com/flash-flex-air/new-flexair-component-internetconnectionstatus/2008/10/</link>
		<comments>http://www.nickkuh.com/flash-flex-air/new-flexair-component-internetconnectionstatus/2008/10/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 13:17:43 +0000</pubDate>
		<dc:creator>Nick Kuh</dc:creator>
				<category><![CDATA[Adobe Flash, Flex and Air]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Adobe AIR example]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Flex and Air]]></category>

		<guid isPermaLink="false">http://www.nickkuh.com/?p=75</guid>
		<description><![CDATA[A simple but very useful component for developing AIR applications that need to know whether the user is connected to the internet or not. Choose a reliable url as your sourceURL for the component. Then the InternetConnectionStatus component will monitor that url and keep your application informed about the internet connection status via it&#8217;s connected [...]]]></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.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;source=nickkuh&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: left;">A simple but very useful component for developing AIR applications that need to know whether the user is connected to the internet or not. Choose a reliable url as your sourceURL for the component. Then the InternetConnectionStatus component will monitor that url and keep your application informed about the internet connection status via it&#8217;s connected bindable property!</p>
<p style="text-align: center;"><a href="http://www.nickkuh.com/wp-content/uploads/2008/10/picture-69.png"><img class="size-medium wp-image-76 aligncenter" title="picture-69" src="http://www.nickkuh.com/wp-content/uploads/2008/10/picture-69-300x238.png" alt="" width="300" height="238" /></a></p>
<p style="text-align: left;"><a href="http://nickkuh.googlecode.com/files/InternetConnectionMonitor.zip">Download the example</a></p>
<p style="text-align: left;"><a href="http://nickkuh.googlecode.com/files/InternetConnectionMonitor.air">Download the AIR application installer</a></p>
</p>
<ul class="socialwrap size32 row">
<li class="iconOnly"><a rel="nofollow" target="_blank" class="delicious" href="http://delicious.com/post?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;title=New+Flex%2FAIR+component%3A+keep+track+of+your+user%26%238217%3Bs+Internet+connection+status" title="Bookmark this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status on Delicious"><span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="digg" href="http://digg.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;title=New+Flex%2FAIR+component%3A+keep+track+of+your+user%26%238217%3Bs+Internet+connection+status&amp;bodytext=A+simple+but+very+useful+component+for+developing+AIR+applications+that+need+to+know+whether+the+user+is+connected+to+the+internet+or+not.+Choose+a+reliable+url+as+your+sourceURL+for+the+component.+Then+the+InternetConnectionStatus+component+will+monitor+that+url+and+keep+your+application+informed+about+the+internet+co" title="Digg this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status"><span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="facebook" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;t=New+Flex%2FAIR+component%3A+keep+track+of+your+user%26%238217%3Bs+Internet+connection+status" title="Recommend this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status on Facebook"><span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="reddit" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;title=New+Flex%2FAIR+component%3A+keep+track+of+your+user%26%238217%3Bs+Internet+connection+status" title="Share this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status on Reddit"><span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="stumble" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F&amp;title=New+Flex%2FAIR+component%3A+keep+track+of+your+user%26%238217%3Bs+Internet+connection+status" title="Share this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status with Stumblers"><span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" class="twitter" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.nickkuh.com%2Fflash-flex-air%2Fnew-flexair-component-internetconnectionstatus%2F2008%2F10%2F" title="Tweet this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status on Twitter"><span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="" class="rss" href="http://www.nickkuh.com/flash-flex-air/new-flexair-component-internetconnectionstatus/2008/10/feed" title="Follow this post : New Flex/AIR component: keep track of your user&#8217;s Internet connection status comments"><span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nickkuh.com/flash-flex-air/new-flexair-component-internetconnectionstatus/2008/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

