<?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"
	>

<channel>
	<title>Life According to Duck</title>
	<atom:link href="http://accordingtoduck.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://accordingtoduck.com</link>
	<description>Musings on Coding, Gaming, and Life in General</description>
	<pubDate>Wed, 02 Jun 2010 01:34:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Fixing a locked-up Seagate 7200.11 Series hard drive</title>
		<link>http://accordingtoduck.com/a-ducks-life/fixing-a-locked-up-seagate-720011-series-hard-drive/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/fixing-a-locked-up-seagate-720011-series-hard-drive/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 01:32:32 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[A Duck's Life]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=49</guid>
		<description><![CDATA[I just wanted to share my thanks for a fellow Canadian by the name of Carter who has posted a helpful article on fixing Seagate 7200.11 Series Hard Drives.  I had one of these drives myself which went belly-up.  I was about to ship the drive off to Seagate for a warranty replacement [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to share my thanks for a fellow Canadian by the name of Carter who has posted a <a href='http://www.mapleleafmountain.com/seagatebrick.html'>helpful article on fixing Seagate 7200.11 Series Hard Drives</a>.  I had one of these drives myself which went belly-up.  I was about to ship the drive off to Seagate for a warranty replacement and lose any un-backed-up data on it, when I came across his tutorial.  It saved me dozens hours of recreating existing work.</p>
<p>If you've bought a Seagate drive sometime between November 2008 and say, now, take a peek and see what series the drive is.  If it's a 7200.11, head over to Seagate and perform a firmware update STAT!  The bug that causes these drives to be unreadable is fairly random, and affects the drive on power-on - in other words, if you have the right drive series, and the right firmware, your PC is basically a time-bomb of fail.</p>
<p>Thanks again, Carter!</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/fixing-a-locked-up-seagate-720011-series-hard-drive/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux &#8217;service&#8217; command</title>
		<link>http://accordingtoduck.com/a-ducks-life/fun-with-linux/linux-service-command/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/fun-with-linux/linux-service-command/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 15:56:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Fun with Linux]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=48</guid>
		<description><![CDATA[It seems some Distributions of Linux don't include the 'service' command.  Unfortunately, many great Tutorials assume this command is available, and use it for things like stopping and starting Apache, etc.
Luckily, it's a pretty simple script, and something you can easily create yourself.  I use the nano text editor here, but feel free [...]]]></description>
			<content:encoded><![CDATA[<p>It seems some Distributions of Linux don't include the 'service' command.  Unfortunately, many great Tutorials assume this command is available, and use it for things like stopping and starting Apache, etc.</p>
<p>Luckily, it's a pretty simple script, and something you can easily create yourself.  I use the nano text editor here, but feel free to replace 'nano -w' with 'vi' or whatever your preferred text editor is.</p>
<pre># nano -w /usr/sbin/service</pre>
<p>In your Text Editor, enter this text:</p>
<pre>#!/bin/sh
set -e
/etc/init.d/$1 $2 $3</pre>
<p>Save the file, and then...</p>
<pre># chmod 755 /usr/sbin/service</pre>
<p>This makes service an executable file.</p>
<p>Now you'll be able to do things like:</p>
<pre>service httpd restart
service mysqld stop</pre>
<p>easily!</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/fun-with-linux/linux-service-command/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL Root Password Reset (Linux)</title>
		<link>http://accordingtoduck.com/a-ducks-life/at-the-office/resetting-the-mysql-root-password-on-linux/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/at-the-office/resetting-the-mysql-root-password-on-linux/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 15:24:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[At the Office]]></category>

		<category><![CDATA[Fun with Linux]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=47</guid>
		<description><![CDATA[I ran into a case earlier today where I was setting up a LAMP (Linux, Apache, MySQL, PHP) Server whcih already had most of these components pre-installed.  However, no one was really sure what the MySQL Root User password was - and there clearly was one, as attempts to connect without it failed.
The obvious answer [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a case earlier today where I was setting up a LAMP (Linux, Apache, MySQL, PHP) Server whcih already had most of these components pre-installed.  However, no one was really sure what the MySQL Root User password was - and there clearly was one, as attempts to connect without it failed.</p>
<p>The obvious answer was to reset the Root user password - the method of doing so was less obvious.</p>
<p>First, you need to stop the running mysqld daemon.  First try:</p>
<pre># /etc/init.d/mysqld stop</pre>
<p>If that doesn't work for any reason, try this sequence:<span id="more-47"></span></p>
<pre># find / -name *.pid</pre>
<p>Locate the mysqld.pid file, then:</p>
<pre># cat /path_to/mysqld.pid</pre>
<p>This will return a number pointing to the process we need to stop.  Replace xxxxx below with the returned number.</p>
<pre># kill xxxxx</pre>
<p>Now the current running MySQL has been stopped.  Time to start it up again, with a twist:</p>
<pre># mysqld_safe --skip-grant-tables &amp;</pre>
<p>Now MySQL is running, though very unsecurely.  Quickly now!</p>
<pre># mysql -u root -p</pre>
<p>This will connect you to the MySQL Command Line interface.  If it asks for a password, leave it blank.</p>
<pre>mysql&gt; use mysql</pre>
<p>This command tells MySQL to switch to a database named 'mysql' - where MySQL stores it's own information such as Users.</p>
<pre>mysql&gt; UPDATE user SET password=PASSWORD('new_root_pass')
     WHERE User='root';</pre>
<p>This will update MySQL's User table, changing the password for root to 'new_root_pass'.  YOu may notice that several rows are updated - there's often a 'root' user for each Host (localhost, 127.0.0.1, and your server IP).</p>
<p>Lastly, shut down the Unsecure MySQL Server and restart it as normal.</p>
<pre>mysql&gt;  exit
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start</pre>
<p>MySQL will now start back up with proper User Permissions.</p>
<pre># mysql -u root -p</pre>
<p>You'll now be prompted for a Password.  Enter your NEW root password, and you'll be up and running!</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/at-the-office/resetting-the-mysql-root-password-on-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP: Removing Duplicates in an Array</title>
		<link>http://accordingtoduck.com/web-dev-design/php/php-removing-duplicates-in-an-array/</link>
		<comments>http://accordingtoduck.com/web-dev-design/php/php-removing-duplicates-in-an-array/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 19:54:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=46</guid>
		<description><![CDATA[One thing I keep forgetting is that PHP has a built-in function for removing duplicate items from an array; I usually find myself about halfway through writing such a function when the lightbulb goes off.
$original = array &#40;'pie', 'cake', 'cookies', 'cake'&#41;;
$clean = array_unique&#40;$original&#41;;
The $clean array above would contain one less reference to cake than the [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I keep forgetting is that PHP has a built-in function for removing duplicate items from an array; I usually find myself about halfway through writing such a function when the lightbulb goes off.</p>
<pre class="code php"><span style="color: #000000;">$original</span> = <span style="color: #993399;">array</span> <span style="color: #DB6464;">&#40;</span><span style="color: #333399;">'pie'</span>, <span style="color: #333399;">'cake'</span>, <span style="color: #333399;">'cookies'</span>, <span style="color: #333399;">'cake'</span><span style="color: #DB6464;">&#41;</span>;
<span style="color: #000000;">$clean</span> = <a href="http://www.php.net/array_unique"><span style="color: #339999;">array_unique</span></a><span style="color: #DB6464;">&#40;</span><span style="color: #000000;">$original</span><span style="color: #DB6464;">&#41;</span>;</pre>
<p>The $clean array above would contain one less reference to cake than the $original array.</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/web-dev-design/php/php-removing-duplicates-in-an-array/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rebooting this Blog&#8230;</title>
		<link>http://accordingtoduck.com/a-ducks-life/rebooting-this-blog/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/rebooting-this-blog/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 01:38:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[A Duck's Life]]></category>

		<category><![CDATA[Site-related]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=45</guid>
		<description><![CDATA[2009 was an eventful year - so eventful, in fact, that I practically *forgot* I even had this blog.  I posted once in January, and that was that.
2010 *will* be an eventful year - I've bought a new home with my best friend, fallen in love with an amazing girl, grown my business by leaps [...]]]></description>
			<content:encoded><![CDATA[<p>2009 was an eventful year - so eventful, in fact, that I practically *forgot* I even had this blog.  I posted once in January, and that was that.</p>
<p>2010 *will* be an eventful year - I've bought a new home with my best friend, fallen in love with an amazing girl, grown my business by leaps and bounds, and have a whole series of new challenges ahead - and it only makes sense to reboot this blog and start documenting said adventures!</p>
<p>I'll likely create a new layout for this blog to mark the occasion, but that's certainly not a priority so don't get your hopes up.</p>
<p>And for everyone who's wondering - I haven't forgotten about CoHLCD, and I've finally located my backup of the last functional source code.  I *hope* to have a v2.0 release in the next month, though my current workload might cause problems there.</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/rebooting-this-blog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Duck&#8217;s Timestamp Inserter</title>
		<link>http://accordingtoduck.com/web-dev-design/ducks-timestamp-inserter/</link>
		<comments>http://accordingtoduck.com/web-dev-design/ducks-timestamp-inserter/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 16:13:44 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[Duck's Plugins]]></category>

		<category><![CDATA[Web Dev &amp; Design]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[epoch]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[timestamp]]></category>

		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=42</guid>
		<description><![CDATA[When writing up the Countdown Timer in Flash article yesterday, I stumbled across a need for a fairly simple plugin - one that would output the current Unix Timestamp into a Post's content.  While I could use a plugin such as 'Exec-PHP' to accomplish this, that seemed to fall into the 'breaking eggs with [...]]]></description>
			<content:encoded><![CDATA[<p>When writing up the <a href="http://accordingtoduck.com/web-dev-design/countdown-timer-in-flash/">Countdown Timer in Flash</a> article yesterday, I stumbled across a need for a fairly simple plugin - one that would output the current Unix Timestamp into a Post's content.  While I could use a plugin such as 'Exec-PHP' to accomplish this, that seemed to fall into the 'breaking eggs with a sledgehammer' brand of overkill.</p>
<p>As such, I whipped up a quick Wordpress plugin (as I often do for these tiny problems), and decided to make this one available to the public.  So without further ado, I give you...</p>
<p><strong>Duck's Timestamp Inserter!</strong>  Ok, it could use a more creative title.  Using some pretty simple markup, it allows me to insert the current timestamp, or offsets thereof, into my post content.</p>
<p>&lt;!--ducktime--&gt; becomes 1280401283, while &lt;!--ducktime+5000--&gt; becomes 1280406283 and &lt;!--ducktime-1200--&gt; becomes 1280400083.  If you refresh the page, you'll see these all change.</p>
<p><strong>UPDATE:</strong>  This Plugin is now listed on the WordPress Plugin Repository!  You can <a href='http://wordpress.org/extend/plugins/ducks-timestamp-inserter/'>download Duck's Timestamp Inserter</a> from there - and of course, Ratings are appreciated.  I've released it under GPL3.  If you find it useful, please consider Donating.</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/web-dev-design/ducks-timestamp-inserter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Countdown Timer in Flash</title>
		<link>http://accordingtoduck.com/web-dev-design/countdown-timer-in-flash/</link>
		<comments>http://accordingtoduck.com/web-dev-design/countdown-timer-in-flash/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 21:19:22 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[Flash &amp; ActionScript]]></category>

		<category><![CDATA[Web Dev &amp; Design]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[countdown]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[timer]]></category>

		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=40</guid>
		<description><![CDATA[Recently at work, I was asked to add a Countdown Timer to a few of our pages giving the time remaining until a Sale kicked in.  While I could have whipped this up pretty quickly in Javascript, I decided to use the opportunity to expand my Flash knowledge a little.
One of my key considerations [...]]]></description>
			<content:encoded><![CDATA[<p>Recently at work, I was asked to add a Countdown Timer to a few of our pages giving the time remaining until a Sale kicked in.  While I could have whipped this up pretty quickly in Javascript, I decided to use the opportunity to expand my Flash knowledge a little.</p>
<p>One of my key considerations was using the Server's time, rather than the time of the User's system clock.  This meant passing two Timestamps from PHP to Flash, which luckily is very easy to do.  I'll walk you through the entire design process here.  I'll be using Flash CS3, and ActionScript 2.0.<br />
<span id="more-40"></span></p>
<h4>1. Set up the Document</h4>
<p>In Flash, select <em>File</em>, <em>New</em>, and choose <em>"Flash File (ActionScript 2.0)"</em><br />
Select <em>Modify</em>, <em>Document</em> and change the Document Size.  I'll be using <strong>200px</strong> by <strong>100px</strong> for this example.<br />
Add a New Layer named <strong>Actions</strong>.<br />
In the Timeline, add a Keyframe to <em>Layer 1</em> at <em>Frame 2</em>.<br />
<a class="thickbox" rel="nofollow " href='http://accordingtoduck.com/wp-content/gallery/flashcountdown/step1.jpg' title=''><img src='http://accordingtoduck.com/wp-content/gallery/flashcountdown/thumbs/thumbs_step1.jpg' alt='step1.jpg' class='ngg-singlepic ngg-none' /></a></p>
<h4>2. Add Text Elements</h4>
<p>On Frame 1 of Layer 1, use the Text Tool to create a Text Area that will contain the Countdown Time.  Start this with a Default Text of 00:00:00:00.  If you use a Monospace Font, Alignment won't matter.<br />
Change the Text from 'Static Text' to 'Dynamic Text', and give the Text an Instance Name such as 'time_until'.<br />
To make sure your chosen font is available to the Visitor, we're going to embed part of it.  Click the 'Embed' button, and select 'Numerals'.  Type a Semi-colon in the 'Include these characters:' field. Click OK.<br />
<a class="thickbox" rel="nofollow " href='http://accordingtoduck.com/wp-content/gallery/flashcountdown/step2.jpg' title=''><img src='http://accordingtoduck.com/wp-content/gallery/flashcountdown/thumbs/thumbs_step2.jpg' alt='step2.jpg' class='ngg-singlepic ngg-none' /></a></p>
<h4>3. Add Labels</h4>
<p>Still in Layer 1/Frame 1, create a new Text Area.  Set this area back to Static Text.  Enter the text 'sec', and reduce the font size.  Center this below the rightmost '00'.  Copy (Ctrl+C) this field, and Paste in Place (Ctrl+Shift+V).  Move the copied field under the next set of 00s, and change the text to 'min'.  Repeat for 'hrs' and 'days' with the remaining 00s.<br />
<a class="thickbox" rel="nofollow " href='http://accordingtoduck.com/wp-content/gallery/flashcountdown/step3.jpg' title=''><img src='http://accordingtoduck.com/wp-content/gallery/flashcountdown/thumbs/thumbs_step3.jpg' alt='step3.jpg' class='ngg-singlepic ngg-none' /></a></p>

<h4>4. Add our ActionScript</h4>
<p>Select Frame 1 of the Actions Layer, and press F9 to load the Actions Window.  Add the Code shown in each block below:</p>
<pre class="code javascript">&nbsp;
<span style="color: #339999;">stop</span><span style="color: #DB6464;">&#40;</span><span style="color: #DB6464;">&#41;</span>;
&nbsp;</pre>
<p>This stops the Movie from playing, keeping it at Frame 1.</p>
<pre class="code javascript">&nbsp;
<span style="color: #993399;">this</span>.<span style="color: #339999;">onEnterFrame</span> = <span style="color: #339999;">function</span> <span style="color: #DB6464;">&#40;</span><span style="color: #DB6464;">&#41;</span> <span style="color: #DB6464;">&#123;</span>
	<span style="color: #339999;">var</span> currTime = <span style="color: #DB6464;">&#40;</span>Number<span style="color: #DB6464;">&#40;</span>timeNow<span style="color: #DB6464;">&#41;</span> * <span style="color: #A00000;">1000</span><span style="color: #DB6464;">&#41;</span> + getTimer<span style="color: #DB6464;">&#40;</span><span style="color: #DB6464;">&#41;</span>;
	<span style="color: #339999;">var</span> targTime = Number<span style="color: #DB6464;">&#40;</span>timeThen<span style="color: #DB6464;">&#41;</span> * <span style="color: #A00000;">1000</span>;
	<span style="color: #339999;">var</span> timeLeft = targTime - currTime;
&nbsp;</pre>
<p>This begins our function to update the Countdown Timer.  <em>timeNow</em> and <em>timeThen</em> are UNIX Timestamp values that will be passed in from the server via the <em>flashvars</em> attribute of the embed tag.  We multiply these both by 1000 in order to convert them to a value in milliseconds, rather than seconds.  <em>getTimer</em> returns how long the Flash Movie has been running in milliseconds, and is added to our Current Time to produce a countdown effect.  <em>timeLeft</em> is simply the difference between these two values.</p>
<pre class="code javascript">&nbsp;
	<span style="color: #993399;">if</span> <span style="color: #DB6464;">&#40;</span>timeLeft &lt;= <span style="color: #A00000;">0</span><span style="color: #DB6464;">&#41;</span> <span style="color: #DB6464;">&#123;</span>
		time_until.<span style="color: #339999;">text</span> = <span style="color: #333399;">&quot;00:00:00:00&quot;</span>;
		gotoAndStop<span style="color: #DB6464;">&#40;</span><span style="color: #A00000;">2</span><span style="color: #DB6464;">&#41;</span>;
		<span style="color: #993399;">return</span>;
	<span style="color: #DB6464;">&#125;</span>
&nbsp;</pre>
<p>If we've reached or past the Target Time of our Countdown, proceed to the second frame of the Movie, and stop there.</p>
<pre class="code javascript">&nbsp;
	<span style="color: #339999;">var</span> secs = Math.<span style="color: #339999;">floor</span><span style="color: #DB6464;">&#40;</span>timeLeft / <span style="color: #A00000;">1000</span><span style="color: #DB6464;">&#41;</span>;
	<span style="color: #339999;">var</span> mins = Math.<span style="color: #339999;">floor</span><span style="color: #DB6464;">&#40;</span>secs/<span style="color: #A00000;">60</span><span style="color: #DB6464;">&#41;</span>;
	<span style="color: #339999;">var</span> hrs = Math.<span style="color: #339999;">floor</span> <span style="color: #DB6464;">&#40;</span>mins/<span style="color: #A00000;">60</span><span style="color: #DB6464;">&#41;</span>;
	<span style="color: #339999;">var</span> days = Math.<span style="color: #339999;">floor</span> <span style="color: #DB6464;">&#40;</span>hrs/<span style="color: #A00000;">24</span><span style="color: #DB6464;">&#41;</span>;
&nbsp;</pre>
<p>Since <em>timeLeft</em> is currently measured in milliseconds, we need to determine how many seconds, minutes, hours, and days that represents.</p>
<pre class="code javascript">&nbsp;
	secs = String<span style="color: #DB6464;">&#40;</span>secs % <span style="color: #A00000;">60</span><span style="color: #DB6464;">&#41;</span>;
	mins = String<span style="color: #DB6464;">&#40;</span>mins % <span style="color: #A00000;">60</span><span style="color: #DB6464;">&#41;</span>;
	hrs = String<span style="color: #DB6464;">&#40;</span>hrs % <span style="color: #A00000;">24</span><span style="color: #DB6464;">&#41;</span>;
	days = String<span style="color: #DB6464;">&#40;</span>days<span style="color: #DB6464;">&#41;</span>;
&nbsp;</pre>
<p>The <em>String</em> function here converts the Numerical values into, well, Strings.  The modulus of each timepart is taken so that only the significant portion is kept.  We want an hour to appear as "00:01:00:00", rather than "00:01:60:3600".</p>
<pre class="code javascript">&nbsp;
	<span style="color: #993399;">if</span> <span style="color: #DB6464;">&#40;</span>secs.<span style="color: #339999;">length</span> &lt; <span style="color: #A00000;">2</span><span style="color: #DB6464;">&#41;</span> secs = <span style="color: #333399;">&quot;0&quot;</span> + secs;
	<span style="color: #993399;">if</span> <span style="color: #DB6464;">&#40;</span>mins.<span style="color: #339999;">length</span> &lt; <span style="color: #A00000;">2</span><span style="color: #DB6464;">&#41;</span> mins = <span style="color: #333399;">&quot;0&quot;</span> + mins;
	<span style="color: #993399;">if</span> <span style="color: #DB6464;">&#40;</span>hrs.<span style="color: #339999;">length</span> &lt; <span style="color: #A00000;">2</span><span style="color: #DB6464;">&#41;</span> hrs = <span style="color: #333399;">&quot;0&quot;</span> + hrs;
	<span style="color: #993399;">if</span> <span style="color: #DB6464;">&#40;</span>days.<span style="color: #339999;">length</span> &lt; <span style="color: #A00000;">2</span><span style="color: #DB6464;">&#41;</span> days = <span style="color: #333399;">&quot;0&quot;</span> + days;
&nbsp;</pre>
<p>These lines add 'zero-fill' to each value, ensuring that they are 2 digits long.  If you need a 3-digit field for days, try replacing the last line with:</p>
<pre class="code javascript">&nbsp;
	<span style="color: #993399;">while</span> <span style="color: #DB6464;">&#40;</span>days.<span style="color: #339999;">length</span> &lt; <span style="color: #A00000;">3</span><span style="color: #DB6464;">&#41;</span> days = <span style="color: #333399;">&quot;0&quot;</span> + days;
&nbsp;</pre>
<p>Lastly, we need to output our time to the screen, and close our function.</p>
<pre class="code javascript">&nbsp;
	time_until.<span style="color: #339999;">text</span> = days + <span style="color: #333399;">&quot;:&quot;</span> + hrs
		+ <span style="color: #333399;">&quot;:&quot;</span> + mins + <span style="color: #333399;">&quot;:&quot;</span> + secs;
<span style="color: #DB6464;">&#125;</span>
&nbsp;</pre>
<h4>5. Add our 'Times Up!' Frame</h4>
<p>In the Timeline, select Layer 1, Frame 2.  Add whatever Text or Graphics you'd like here.  This will appear when the Target Time has been reached.</p>
<h4>6. Publish the .SWF</h4>
<p>First, save the Document - Flash will publish to the same folder as the Document by default.  Next, go <em>File</em>, <em>Publish Settings...</em> and detoggle the HTML file - we're going to need to customize it anyway, and I prefer my code a little less bloated than Flash's output.  Only the .swf output should be enabled.  Click <em>Publish</em>, and there should now be a .swf in the same folder as your Document.</p>
<h4>7. Test it out!</h4>
<p>Load the .swf file in a browser, and... it'll likely skip straight to Frame 2.  Since no timestamps were supplied via flashvars, both <em>timeNow</em> and <em>timeThen</em> are undefined, which causes our <em>timeLeft</em> to evaluate to zero.</p>
<p>Luckily, testing the timer is very simple.  In your browser window, simply add the two values to the .swf file's address.  Just use a small number for timeNow, and a larger number for timeThen.  The URL should be something like:<br />
file:///C:/local_path/flashtimer.swf<strong>?timeNow=5&timeThen=18000</strong></p>
<p>If you've done that correctly, you should now have a working countdown timer!  The last step is loading this from your website, using PHP to pass in the timestamps required.</p>
<h4>8. The PHP/HTML Document</h4>
<p>Since you'll likely be adding this to part of another document, I'll only cover the necessary HTML here.</p>
<p><code><br />
&lt;embed src='flashtimer.swf' width='200' height='100'<br />
flashvars='timeNow=<strong>&lt;?=time();&gt;</strong>&timeThen=1230163200'<br />
type='application/x-shockwave-flash' /&gt;<br />
</code><br />
Note that <em>timeNow</em> is passed in as the current Timestamp by PHP when the page loads. In this example, timeThen is Christmas Day 2008, a timestamp I simply generated using <a href='http://www.epochconverter.com' target='_blank'>Epoch Converter</a>.</p>
<p>The result will look something like this:<br />
<embed src='/flashtimer2.swf' width='200' height='100' flashvars='timeNow=1280401283&timeThen=1230163200' type='application/x-shockwave-flash' /></p>
<p>You'll obviously want to improve on the timer visually to match your site, or the occasion you're counting to.  Oh, if you want to be really lazy, you can just <a href='/flashtimer.fla'>Download the .FLA file</a>.  I don't mind, really <img src='http://accordingtoduck.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h4>9. Using with Wordpress</h4>
<p>If you're placing your Countdown Timer in a Wordpress post (like mine), you may have some difficulty using PHP to add the timestamp.  Luckily, I whipped up a quick Wordpress Plugin to do just that.  <a href="http://accordingtoduck.com/web-dev-design/ducks-timestamp-inserter/">Duck's Timestamp Inserter</a> is a small, free plugin that can output timestamps into Wordpress content.</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/web-dev-design/countdown-timer-in-flash/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Paint Thinner + Water + Plastic = &#8230;?</title>
		<link>http://accordingtoduck.com/a-ducks-life/paint-thinner-water-plastic-keys/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/paint-thinner-water-plastic-keys/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 00:17:26 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[A Duck's Life]]></category>

		<category><![CDATA[The Great To-Do List]]></category>

		<category><![CDATA[Warhammer 40K]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=37</guid>
		<description><![CDATA[Well, my G15 Refinishing is now on hold indefinitely.  Somehow, the Numpad Enter key, which was (along with every other key) soaking in a jar of water to release the paint thinner, turned into jelly and puffed up.  The other keys, which all had the identical treatment, remain unaffected.
I'll probably look for a [...]]]></description>
			<content:encoded><![CDATA[<p>Well, my G15 Refinishing is now on hold indefinitely.  Somehow, the Numpad Enter key, which was (along with every other key) soaking in a jar of water to release the paint thinner, turned into jelly and puffed up.  The other keys, which all had the identical treatment, remain unaffected.</p>
<p>I'll probably look for a used/broken G15 or G11, and just swipe the keytops from it.  However, this definitely pushed this to the end of the project list.</p>
<p>Sheeb's Tau Battlesuits are nearly completed, as is the Necron 'Hand of Despair' Terrain piece.  I'll be making some related terrain pieces soon, and creating templates so others can make the same Hand.</p>
<p>I'm going to be out of town all weekend, so the list itself won't really get knocked down all that much for a while.  Ah well, I deserve a *few* days off <img src='http://accordingtoduck.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/paint-thinner-water-plastic-keys/feed/</wfw:commentRss>
		</item>
		<item>
		<title>G15 Refinishing Woes</title>
		<link>http://accordingtoduck.com/a-ducks-life/g15-refinishing-woes/</link>
		<comments>http://accordingtoduck.com/a-ducks-life/g15-refinishing-woes/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 15:05:21 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[A Duck's Life]]></category>

		<category><![CDATA[The Great To-Do List]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=35</guid>
		<description><![CDATA[After soaking the Keys in Brake Fluid all night, and giving them a vigorous scrubbing this morning, maybe 30% of the paint has come loose - and that's being very generous.  I'm back to looking for another method of paint stripping to get the Keys down to their transparent plastic bases.
On top of that, [...]]]></description>
			<content:encoded><![CDATA[<p>After soaking the Keys in Brake Fluid all night, and giving them a vigorous scrubbing this morning, maybe 30% of the paint has come loose - and that's being very generous.  I'm back to looking for another method of paint stripping to get the Keys down to their transparent plastic bases.</p>
<p>On top of that, I had the brilliant idea of giving the main plastic pieces (which were spraypainted with Krylon Fusion yesterday) a quick Clear Coat.  Bad idea.  It caused a fair bit of the Krylon Fusion to bubble up, and now I have to strip the paint off these as well.</p>
<p>So basically, the only part that's gone right in this whole project has been replacing the Blue LEDs with Red Ones - assuming you don't count the small soldering iron burn I self-inflicted.  Hopefully this project turns around soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/a-ducks-life/g15-refinishing-woes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scratch One Website!</title>
		<link>http://accordingtoduck.com/web-dev-design/scratch-one-website/</link>
		<comments>http://accordingtoduck.com/web-dev-design/scratch-one-website/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 05:38:01 +0000</pubDate>
		<dc:creator>Duck L'Orange</dc:creator>
		
		<category><![CDATA[A Duck's Life]]></category>

		<category><![CDATA[The Great To-Do List]]></category>

		<category><![CDATA[Web Dev &amp; Design]]></category>

		<guid isPermaLink="false">http://accordingtoduck.com/?p=34</guid>
		<description><![CDATA[After a few hours of humming and hawing over Wordpress Themes and Plugins, Our Home Cookbook is now online.  Though I did manipulate the theme a fair bit (and intend to do so more later), credit for the original design still needs to be given to BrightCherry Web Design.
Now I just need to give [...]]]></description>
			<content:encoded><![CDATA[<p>After a few hours of humming and hawing over Wordpress Themes and Plugins, <a href="http://ourhomecookbook.com">Our Home Cookbook</a> is now online.  Though I did manipulate the theme a fair bit (and intend to do so more later), credit for the original design still needs to be given to <a href="http://www.brightcherry.co.uk/">BrightCherry</a> Web Design.</p>
<p>Now I just need to give my mom a quick tutorial on blogging with WordPress!</p>
<p>As an interesting side note, I found a small bug in my 'Display Category Children' sidebar widget, which I resolved as well.  I may end up releasing this Widget soon, since it can be rather helpful, despite being really simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://accordingtoduck.com/web-dev-design/scratch-one-website/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
