<?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>The Mountain Of Lightbulbs &#187; Tutorials</title>
	<atom:link href="http://www.razpeel.com/blog/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.razpeel.com/blog</link>
	<description>WebDevelopment - News &#124;&#124; Work &#124;&#124; Tutorials</description>
	<lastBuildDate>Mon, 17 May 2010 17:16:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash Tracer For Firefox 3.5</title>
		<link>http://www.razpeel.com/blog/tutorials/flash-tracer-for-firefox-3-5/</link>
		<comments>http://www.razpeel.com/blog/tutorials/flash-tracer-for-firefox-3-5/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 03:22:01 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[FireFox 3]]></category>
		<category><![CDATA[FireFox 3.5]]></category>
		<category><![CDATA[Flash Add-ons]]></category>
		<category><![CDATA[Flash Log]]></category>
		<category><![CDATA[Flash Tracer]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=400</guid>
		<description><![CDATA[I just installed Flash Tracer on the newest version of Firefox (currently 3.5.3), and I wanted to shed some light on the steps you will need to take to get it working.
The first think you will notice is that Alessandro Crugnola, the talented creator of this add-on, no longer continues it&#8217;s development, so if you [...]]]></description>
			<content:encoded><![CDATA[<p>I just installed Flash Tracer on the newest version of Firefox (currently 3.5.3), and I wanted to shed some light on the steps you will need to take to get it working.</p>
<p>The first think you will notice is that Alessandro Crugnola, the talented creator of this add-on, no longer continues it&#8217;s development, so if you visit it&#8217;s page on the Mozilla Add-ons website (<a href="https://addons.mozilla.org/en-US/firefox/addon/3469">https://addons.mozilla.org/en-US/firefox/addon/3469</a>), it does not give you the option to install it, instead telling you: <em>&#8220;This add-on is for older versions of Firefox&#8221;</em>. You can still install it by loading the add-ons .xpi file though, which is located on its home page <a href="http://www.sephiroth.it/firefox/flashtracer/">http://www.sephiroth.it/firefox/flashtracer/</a> (The link is <a href="http://www.sephiroth.it/examples/firefox/extensions/flashtracer.xpi">here</a> if your feeling lazy).</p>
<p>Next you will need to tell Firefox that you are comfortable using out of date add-ons. Open a new browser window or tab, and type <em>about:config</em> into the address bar as shown below.</p>
<p><img class="size-full wp-image-402" title="ConfigAddressBar" src="http://www.razpeel.com/blog/wp-content/uploads/2009/10/ConfigAddressBar.jpg" alt="Navigation Bar Preview" width="140" height="30" /></p>
<p>After promising Mozilla that you will be careful, you will see a list of the Firefox configuration details. Right click anywhere on this page and create a new <strong>Boolean</strong>.</p>
<p><img class="size-full wp-image-404" title="CreateNewBoolean" src="http://www.razpeel.com/blog/wp-content/uploads/2009/10/CreateNewBoolean.jpg" alt="Inserting New Boolean Example" width="500" height="364" /></p>
<p>Give your new Boolean the following name: <strong>extensions.checkCompatability</strong>.</p>
<p><img class="size-full wp-image-405" title="EnterBooleanName" src="http://www.razpeel.com/blog/wp-content/uploads/2009/10/EnterBooleanName.jpg" alt="Enter Boolean Name Preview" width="321" height="172" /></p>
<p>And finally, set it&#8217;s value to <strong>false</strong>.</p>
<p><img class="size-full wp-image-406" title="SetBooleanValue" src="http://www.razpeel.com/blog/wp-content/uploads/2009/10/SetBooleanValue.jpg" alt="Set Boolean Value Example" width="304" height="164" /></p>
<p>Restart Firefox and your add-on should now load correctly.<br />
Click &gt; <em>Tools</em> &gt; <em>Flash Tracer</em> to open the Flash Log and you should see something like this:</p>
<p><img class="size-full wp-image-407" title="FlashTracerRunning" src="http://www.razpeel.com/blog/wp-content/uploads/2009/10/FlashTracerRunning.jpg" alt="Flash Tracer Running In Firefox 3.5" width="301" height="423" /></p>
<p>If you don&#8217;t see the text inside it, you might have to configure Flash Tracer to read the correct file. You can do this by opening the preferences panel, (click the small wrench icon in the bottom right hand corner of the window) and browsing to the correct location. If you have Flash Player 9 forwards, It&#8217;s probably in one of these locations:</p>
<ul>
<li><strong>Osx:</strong> <em><strong>{user}</strong>\Library\Preferences\Macromedia\Flash Player\Logs\flashlog.txt</em></li>
<li><strong>Windows XP:</strong> <em>C:\Documents and Settings\<strong>{user}</strong>\Application Data\Macromedia\Flash Player\Logs\flashlog.txt</em>.</li>
<li><strong>Windows Vista:</strong> <em>C:\Users\<strong>{user}</strong>\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt</em></li>
</ul>
<p>If you can&#8217;t find the file at the any of the above locations, or it&#8217;s not picking up trace statements when you know it should be, I&#8217;d suggest reading through this fantastic post by <a href="http://yourpalmark.com/2005/07/01/trace-from-the-browser-using-standard-trace/">Mark Walters on correctly setting up Flash Player&#8217;s error reporting.</a></p>
<p><span style="text-decoration: underline;">Random Short Story</span><br />
A year or so back I was playing a Flash game on NewGrounds and hadn&#8217;t shut down the Mac Console (which was still reading through the error log), and I noticed the following message: &#8220;need to implement score saving still, sorry!!&#8221;.<br />
It&#8217;s since been fixed, but I thought it was hilarious at the time, and as such I&#8217;ve tried to make a point of leaving funny messages hidden inside anything I&#8217;m not being paid to create. I thoroughly encourage you to do the same!</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot; Hope This Helps! :] &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/flash-tracer-for-firefox-3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Directory Lists (With Php)</title>
		<link>http://www.razpeel.com/blog/tutorials/xml-directory-lists-with-php/</link>
		<comments>http://www.razpeel.com/blog/tutorials/xml-directory-lists-with-php/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 11:15:21 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Flash Directory Lists]]></category>
		<category><![CDATA[Flash XML Directory List]]></category>
		<category><![CDATA[Flash XML Directory Lists]]></category>
		<category><![CDATA[PHP Directory List]]></category>
		<category><![CDATA[PHP Directory Lists]]></category>
		<category><![CDATA[XML Directory List]]></category>
		<category><![CDATA[XML Directory Lists]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=377</guid>
		<description><![CDATA[Here is a snippet of php code that when run, will produce an XML markup of the images contained within a directory.
This is great is you are building a flash sideshow or similar and want to remove the dependency that comes with hand coding XML files.
I added a bunch of comments, feel free to let [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a snippet of php code that when run, will produce an XML markup of the images contained within a directory.<br />
This is great is you are building a flash sideshow or similar and want to remove the dependency that comes with hand coding XML files.</p>
<p>I added a bunch of comments, feel free to let me know if anything needs explaining in greater detail.</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> DirDisplay<span style="color: #009900;">&#40;</span><span style="color: #000088;">$LocDir</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// list of valid image extensions to look for</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$valid_ext</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$valid_ext</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$valid_ext</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;gif&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$valid_ext</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bmp&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// init XML output</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;Images&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// open directory</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$TrackDir</span><span style="color: #339933;">=</span><span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$LocDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// loop through files</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$TrackDir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// check for non-parent file names</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// reads file extension</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strrchr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// makes sure file has allowed extension</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span><span style="color: #339933;">,</span><span style="color: #000088;">$valid_ext</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// adds file to XML output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;Image&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;![CDATA['</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">.</span><span style="color: #0000ff;">']]&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;/Image&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// end XML output</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;/Images&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// close open directory</span><br />
&nbsp; &nbsp; <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$TrackDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #339933;">@</span> DirDisplay<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>And here is an example output. I&#8217;ll post up a demo using this xml markup in a future post.</p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Images<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[Image_01.jpg]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[Image_02.jpg]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[Image_03.jpg]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[Image_04.jpg]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Images<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p><a href="http://www.razpeel.com/blog/wp-content/uploads/2009/10/XmlImageList.rar">Here&#8217;s a link to download the file</a>, hope it helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/xml-directory-lists-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Flash Countdowns And Timers</title>
		<link>http://www.razpeel.com/blog/tutorials/simple-flash-countdowns-and-timers/</link>
		<comments>http://www.razpeel.com/blog/tutorials/simple-flash-countdowns-and-timers/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 07:32:18 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=303</guid>
		<description><![CDATA[
I get asked for help doing different variations of Countdowns and Timers all the time, hopefully this post will shed some light on things. 
I&#8217;ll try cover and explain the four variations I get asked about the most but between them you should be able to create any of the other variations with ease.


1) Simple [...]]]></description>
			<content:encoded><![CDATA[<p>
I get asked for help doing different variations of Countdowns and Timers all the time, hopefully this post will shed some light on things. </p>
<p>I&#8217;ll try cover and explain the four variations I get asked about the most but between them you should be able to create any of the other variations with ease.
</p>
<p></p>
<p><strong>1) Simple Countdown In Seconds </strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> countDownTime<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> startTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> updateTimer<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> updateTimer <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">secondsUTC</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> timeRemaining<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>startTimeUTC <span style="color: #000066; font-weight: bold;">+</span> countDownTime<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #004993;">secondsUTC</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>
  Pretty simple code, all we are doing is setting a start time and comparing the current time to it when the update function runs.<br />
  Note: The above snippet doesn&#8217;t actually do anything with the counter or perform any task when the counter reaches zero. I&#8217;m rather just showing how to calculate time, implementation of the code is up to you!
</p>
<p>Here is a sample output:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CountDown_356189623"
			class="flashmovie"
			width="480"
			height="60">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountDown.swf" />
	<param name="scale" value="noscale" />
	<param name="bgcolor" value="#F3FBFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountDown.swf"
			name="fm_CountDown_356189623"
			width="480"
			height="60">
		<param name="scale" value="noscale" />
		<param name="bgcolor" value="#F3FBFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>
Lets take a closer look at the code now.<br />
<br />
Line 2 defines <em>startTimeUTC</em>, which is populated by creating a new <em>Date()</em> object. <br />
Note: The <em>Date</em>() object defaults to the current date and time when instantiated without any parameters, so we can immediately call it&#8217;s <em>getTime()</em> method and store the result.<br />
We should now have a funny looking number like: 1248677922937, which is actually a <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">UTC</a> representation of the present time in milliseconds. On this occasion however, we just need the seconds, so we would divide that number by 1000, (1 second is 1000 milliseconds).<br />
Now every time the update function runs, we simply replicate this action to create a new <em>Date(), </em>and compare it  to the <em>Date()</em> we stored in <em>startTimeUTC</em>.</p>
<p></p>
<p><strong>2) Simple Count Up In Seconds</strong></p>
<p>
Measuring time expired is really just the above backwards.</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> startTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> traceOutput<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> traceOutput <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> newTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> timeExpired<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>newTimeUTC <span style="color: #000066; font-weight: bold;">-</span> startTimeUTC<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Example:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CountUp_1452450406"
			class="flashmovie"
			width="480"
			height="60">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountUp.swf" />
	<param name="scale" value="noscale" />
	<param name="bgcolor" value="#F3FBFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountUp.swf"
			name="fm_CountUp_1452450406"
			width="480"
			height="60">
		<param name="scale" value="noscale" />
		<param name="bgcolor" value="#F3FBFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p></p>
<p> <strong>3) Countdown To Date</strong></p>
<p>This variation builds on the first and second countdown examples but brings more to the sandbox to play with, lets jump straight into the code.</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> futureTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2010</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> updateCounter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> updateCounter <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> newTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> timeRemainingUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <br />
&nbsp; &nbsp; &nbsp; &nbsp; futureTimeUTC <span style="color: #000066; font-weight: bold;">-</span> newTimeUTC<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockSecondsPast<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeRemainingUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockMinutesPast<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeRemainingUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">60000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockHoursPast<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeRemainingUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">3600000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockDaysPast<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeRemainingUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">86400000</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p> This time we have manually set the <em>Date()</em> to January 1st, 2010 (The first month is 0, not 1). The time will default to 00:00am since it was not set, but this is what we want, new years!!<br/><br />
Once we have calculated <em>timeRemaining</em> in the update function, we can parse the information we need from it. Remember it is currently a UTC format number, so think of it as the number of milliseconds, with that in mind it isn&#8217;t hard to find what we need. <br />
Note: The % operator is modulus, it returns the remainder of a number.</p>
<ul>
<li>Seconds = (UTC Value / 1000 Milliseconds) Mod 60</li>
<li>Minutes = (UTC Value / (1000 * 60 Seconds)) Mod 60</li>
<li>Hours = (UTC Value / (1000 * 60 * 60 Minutes)) Mod 24</li>
<li>Days = (UTC Value / (1000 * 60 * 60 * 24 Hours))</li>
</ul>
<p> If you didn&#8217;t catch it, we are just dividing by the amount of Milliseconds in each. Here is an example: </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CountDownDate_1009052733"
			class="flashmovie"
			width="480"
			height="60">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountDownDate.swf" />
	<param name="scale" value="noscale" />
	<param name="bgcolor" value="#F3FBFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountDownDate.swf"
			name="fm_CountDownDate_1009052733"
			width="480"
			height="60">
		<param name="scale" value="noscale" />
		<param name="bgcolor" value="#F3FBFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p></p>
<p><strong>4) Counter From Past Date</strong></p>
<p>The last variation is really just the previous example backwards, for when you need to count forward from a date in the past.</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> startTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2009</span><span style="color: #000066; font-weight: bold;">,</span> 06<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">26</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> updateCounter<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> updateCounter <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> newTimeUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> timeExpiredUTC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; newTimeUTC <span style="color: #000066; font-weight: bold;">-</span> startTimeUTC<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockSecondsExpired<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeExpiredUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockMinutesExpired<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeExpiredUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">60000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockHoursExpired<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeExpiredUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">3600000</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> clockDaysExpired<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> =<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>timeExpiredUTC <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">86400000</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p> And an example to match: </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CountUpDate_1151283368"
			class="flashmovie"
			width="480"
			height="60">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountUpDate.swf" />
	<param name="scale" value="noscale" />
	<param name="bgcolor" value="#F3FBFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/07/CountUpDate.swf"
			name="fm_CountUpDate_1151283368"
			width="480"
			height="60">
		<param name="scale" value="noscale" />
		<param name="bgcolor" value="#F3FBFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/simple-flash-countdowns-and-timers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash As3 Event.MOUSE_LEAVE Not Firing.</title>
		<link>http://www.razpeel.com/blog/tutorials/flash-as3-eventmouse_leave-not-firing/</link>
		<comments>http://www.razpeel.com/blog/tutorials/flash-as3-eventmouse_leave-not-firing/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 08:58:33 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Event.MOUSE_LEAVE]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[MOUSE_LEAVE]]></category>
		<category><![CDATA[MOUSE_LEAVE Broken]]></category>
		<category><![CDATA[MOUSE_LEAVE Issue]]></category>
		<category><![CDATA[MOUSE_LEAVE Not Firing]]></category>
		<category><![CDATA[MOUSE_LEAVE Not Working]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=133</guid>
		<description><![CDATA[Really quick post this time. Wanted to share some recent found knowledge that i wish i had known twenty minutes prior to testing functionality in an RIA earlier on tonight.
1stage.addEventListener&#40;Event.MOUSE_LEAVE, exitHandler&#41;;

    This will not work in the Flash IDE! The  embedded player just never fires the event.
    The [...]]]></description>
			<content:encoded><![CDATA[<p>Really quick post this time. Wanted to share some recent found knowledge that i wish i had known twenty minutes prior to testing functionality in an RIA earlier on tonight.</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_LEAVE</span><span style="color: #000066; font-weight: bold;">,</span> exitHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>
    This will not work in the Flash IDE! The  embedded player just never fires the event.<br />
    The only work around i could find is to publish the swf and view it in a browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/flash-as3-eventmouse_leave-not-firing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>As3 CData Binding</title>
		<link>http://www.razpeel.com/blog/tutorials/as3-cdata-binding/</link>
		<comments>http://www.razpeel.com/blog/tutorials/as3-cdata-binding/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 09:15:13 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ActionSctipt 3]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[CDATA]]></category>
		<category><![CDATA[CDATA Binding]]></category>
		<category><![CDATA[Flash CData]]></category>
		<category><![CDATA[XML Binding]]></category>
		<category><![CDATA[Xml CData]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=106</guid>
		<description><![CDATA[
	I just manged to get some code working that has had me banging my head against the wall for the last couple of hours.
	The goal was simple, send XHTML markup to PHP. Horray says me, should be fairly straight forward!
	I&#8217;ll just pop a &#60;!CDATA[..]]&#62;&#62; tag around the nodes that store the markup so the tags [...]]]></description>
			<content:encoded><![CDATA[<p>
	I just manged to get some code working that has had me banging my head against the wall for the last couple of hours.<br />
	The goal was simple, send <em>XHTML</em> markup to <em>PHP</em>. Horray says me, should be fairly straight forward!<br />
	I&#8217;ll just pop a <em>&lt;!CDATA[..]]&gt;&gt;</em> tag around the nodes that store the markup so the tags will not be parsed.<br />
Then i set off about my usual workflow, and soon enough, i have some actionscript which should be both reading and writing to my <em>.xml</em> file.</p>
<p>Everything looks great, time to test it out!</p>
<p>
	<strong>Problem!</strong>
</p>
<p><div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// Wraps a single content node with required tags.</span><br />
<span style="color: #009900; font-style: italic;">// Note tag = &quot;Name&quot; &amp; contents = &quot;Raz Peel&quot;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> stringToNode <span style="color: #000000;">&#40;</span>tag<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> contents<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span> <span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;&lt;![CDATA[&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#123;</span>contents<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;]]&gt;&quot;</span><span style="color: #000066; font-weight: bold;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
</p>
<p>
	My first element comes out as such.
</p>
<div class="asCode">
<p>
        &lt;<span class="xmlTag">Name</span>&gt;<br />
        + &quot;<br />
        &lt;![CDATA[&quot; + {contents} + &quot;]]&gt;<br />
        &quot; +<br />
        &lt;/<span class="xmlTag">Name</span>&gt;
	</p>
</div>
<p>
	Obviously this is not working at all as it should, i take it my XML isn&#8217;t formatted correctly.<br />
	Back into code I rewrite my function to the follows:
</p>
<p><div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span> <span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span> <span style="color: #000000;">&#123;</span>contents<span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
</p>
<p>
	This result was better, but still very much incorrect.
</p>
<div class="asCode">
<p>
    	&lt;<span class="xmlTag">Name</span>&gt;&lt;![CDATA[ {contents} ]]&gt;&lt;/<span class="xmlTag">Name</span>&gt;
	</p>
</div>
<p>
	The contents variable was being parsed as a string rather than a variable. <br />
	I jumped back into the code to try something else.
</p>
<p><div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span> <span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><span style="color: #990000;">&quot;&lt;![CDATA[&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#123;</span>contents<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#123;</span><span style="color: #990000;">&quot;]]&gt;&quot;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
</p>
<p>
	This must work right? Apparantly not, result was:
</p>
<div class="asCode">
<p>
    	&lt;<span class="xmlTag">Name</span>&gt;&amp;lt;![CDATA[ Raz Peel ]]&amp;gt;&lt;/<span class="xmlTag">Name</span>&gt;
	</p>
</div>
<p>
	This is the point where i consulted the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package-summary.html">Adobe LiveDocs</a><br />
    and then our <a href="http://oreilly.com/catalog/9780596526948/">Essential ActionScript 3.0</a> book. <br />
    Colin, unfortunatley, confirmed that i wasn&#8217;t doing anything wrong, weird! Ten minutes on google found me on <a href="http://jessewarden.com/">Jesse Warden&#8217;s blog</a> reading this <a href="http://jessewarden.com/2007/06/e4x-xml-binding-cdata.html">post</a>. <br />
As such i changed my code to this:</p>
<p><div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339966; font-weight: bold;">function</span> cdata<span style="color: #000000;">&#40;</span>theURL<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span> <span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;&lt;![CDATA[&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> theURL <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;]]&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span> <span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#123;</span>cdata<span style="color: #000000;">&#40;</span>contents<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&lt;/</span><span style="color: #000000;">&#123;</span>tag<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
</p>
<p>
	Result?
</p>
<div class="asCode">
<p>
    	&lt;<span class="xmlTag">Name</span>&gt;&lt;![CDATA[Raz Peel]]&gt;&lt;/<span class="xmlTag">Name</span>&gt;
	</p>
</div>
<p>
	Yay, success!!! <br /> I&#8217;ve no idea if this is suppose to work like this or not, but it does.<br />
    Thanks for sharing Jesse!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/as3-cdata-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Rotating Images (As3)</title>
		<link>http://www.razpeel.com/blog/tutorials/rotating-images/</link>
		<comments>http://www.razpeel.com/blog/tutorials/rotating-images/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 00:31:40 +0000</pubDate>
		<dc:creator>Raz</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[As3]]></category>
		<category><![CDATA[Changing Images]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Image Gallery]]></category>
		<category><![CDATA[Image Loop]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Images Fade In Fade Out]]></category>
		<category><![CDATA[Rotating]]></category>
		<category><![CDATA[Rotating Images]]></category>
		<category><![CDATA[Rotating Images As3]]></category>
		<category><![CDATA[Website Changing Images]]></category>

		<guid isPermaLink="false">http://www.razpeel.com/blog/?p=39</guid>
		<description><![CDATA[
In  the last week of talking in various channels, at least a few people have asked for help with the code to dynamically rotate several images in a loop.


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_rotatingimages_final_1808540473"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimages_final.swf" />
	<param name="play" value="true" />
	<param name="quality" value="high" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimages_final.swf"
			name="fm_rotatingimages_final_1808540473"
			width="500"
			height="500">
		<param name="play" value="true" />
		<param name="quality" value="high" />
	<!--<![endif]-->
		

	
		
	


	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

  I’ll show you two different ways you can do this, both leading to the same result. [...]]]></description>
			<content:encoded><![CDATA[<p>
In  the last week of talking in various channels, at least a few people have asked for help with the code to dynamically rotate several images in a loop.
</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_rotatingimages_final_944768895"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimages_final.swf" />
	<param name="play" value="true" />
	<param name="quality" value="high" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimages_final.swf"
			name="fm_rotatingimages_final_944768895"
			width="500"
			height="500">
		<param name="play" value="true" />
		<param name="quality" value="high" />
	<!--<![endif]-->
		
<p>
	<a href="http://adobe.com/go/getflashplayer"><br />
		<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
	</a>
</p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>
  I’ll show you two different ways you can do this, both leading to the same result. You can look at the method i would use, (which includes the use of <a href="http://code.google.com/p/tweener/">Tweener</a>, and another way using Flash’s built in tween system. </p>
<p>  If you want to follow along using my method, i have a pre-prepared file that you can start with at this <a href="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimagesfla.zip">link.</a><br />
  <span style="font-weight: lighter; font-size: 0.85em;"><em>The images used in this tutorial are not my own, rather by one of my favorite digital artists <a href="http://gallery.artofgregmartin.com/" target="_blank">Greg Martin</a>.</em></span>
</p>
<p>
	<strong><br />
	1) My way, using Tweener</strong>.
</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #009900; font-style: italic;">// import Tweener</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> caurina<span style="color: #000066; font-weight: bold;">.</span>transitions<span style="color: #000066; font-weight: bold;">.</span>Tweener<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// imageNum will hold the current image we are viewing,</span><br />
<span style="color: #009900; font-style: italic;">// imgArray will store a list of all the images in use</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> imageNum<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> imgArray<span style="color: #000066; 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><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/* create a for loop construct to iterate through all the display objects on the stage<br />
the code that loops takes each display object and stores it in our imgArray,<br />
and then changes the alpha value of each one to zero so nothing is visible on screen */</span><br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
imgArray<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getChildAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
imgArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// create a function called tweenImg. You can then call this function whenever we want the image to change</span><br />
<span style="color: #339966; font-weight: bold;">function</span> tweenImg <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> secondNum<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//define a variable to hold the index of the next image to be shown</span><br />
<br />
<span style="color: #009900; font-style: italic;">//tell Tweener to create a new tween which will wait 1.5 seconds and then set the alpha property of the current image to 0.</span><br />
Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>imgArray<span style="color: #000000;">&#91;</span>imageNum<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">delay</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> transition<span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;easeOutCubic&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//check if the current image is the last one in the list. If so, reset the index to 0, otherwise increase the index by 1.</span><br />
<span style="color: #009900; font-style: italic;">//tells the next image to fade in</span><br />
imageNum <span style="color: #000066; font-weight: bold;">&gt;</span>= imgArray<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">?</span> imageNum = <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">:</span> secondNum = <span style="color: #000066; font-weight: bold;">++</span>imageNum<span style="color: #000066; font-weight: bold;">;</span><br />
Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>imgArray<span style="color: #000000;">&#91;</span>secondNum<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">delay</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> transition<span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;easeOutCubic&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000066; font-weight: bold;">:</span>tweenImg<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// start the loop cycle by fading in the first image and calling the tweenImg function when it’s finished.</span><br />
Tweener<span style="color: #000066; font-weight: bold;">.</span>addTween<span style="color: #000000;">&#40;</span>imgArray<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">time</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000066; font-weight: bold;">:</span>tweenImg<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>
That’s all! You now have a series of images that all fade in and  then out continuously. Finished files are available at <a href="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimagesfla_finished.zip">this link</a>. </p>
<p>
	<strong>2) The other way, using the bulit in tweening engine.</strong></p>
<p>    I wrote the alternative way of achieving the same result using flash’s own inferior tweening system.<br />
    I&#8217;m not going to post it here though, instead you&#8217;ll find the complete working files for this method, along with the one previously discussed at <a href="http://www.razpeel.com/blog/wp-content/uploads/2009/01/rotatingimagesfla_finished.zip">this link</a>.</p>
<p>Good luck! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.razpeel.com/blog/tutorials/rotating-images/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
