<?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>The web page of Dan</title>
	<atom:link href="http://www.thewebpageofdan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thewebpageofdan.com</link>
	<description></description>
	<pubDate>Fri, 07 Nov 2008 22:30:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>ActionScript Timer class seem offset/inaccurate/way off? It is!</title>
		<link>http://www.thewebpageofdan.com/2008/11/01/actionscript-timer-class-seem-offset-inaccurate-way-off-it-is/</link>
		<comments>http://www.thewebpageofdan.com/2008/11/01/actionscript-timer-class-seem-offset-inaccurate-way-off-it-is/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 02:20:21 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Flash/ActionScript]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/?p=207</guid>
		<description><![CDATA[Something I discovered a while ago has popped up in a recent project and I decided to share my experience.  To put it in a nutshell, the Timer class is not what you think it is (a perfect timer); it is actually influenced by the user&#8217;s frame rate.  Let&#8217;s take a look at [...]]]></description>
			<content:encoded><![CDATA[<p>Something I discovered a while ago has popped up in a recent project and I decided to share my experience.  To put it in a nutshell, <strong>the Timer class is not what you think it is</strong> (a perfect timer); it is actually influenced by the user&#8217;s frame rate.  Let&#8217;s take a look at what it says right in the documentation that can be found in the Flash Help book within Flash CS or at the <a href="http://livedocs.adobe.com/flex/2/langref/index.html?flash/utils/Timer.html">online Adobe® Flex™ 2 Language Reference</a>:</p>
<blockquote><p>
You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. <strong>Depending on the SWF file&#8217;s framerate</strong> or Flash Player&#8217;s environment (available memory and other factors), <strong>Flash Player may dispatch events at slightly offset intervals</strong>. For example, if a SWF file is set to play at 10 frames per second [fps], which is 100 millisecond intervals, but your timer is set to fire an event at 80 milliseconds, Flash Player will fire the event close to the 100 millisecond interval. Memory-intensive scripts may also offset the events.</p>
</blockquote>
<p><span id="more-207"></span><br />
<a href="http://flashquartermaster.com">Tom Coxen</a> has <a href="https://bugs.adobe.com/jira/browse/FP-34">reported this bug</a> and released some information regarding it.  Below is some code he posted to reproduce the bug:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* Timer inacurracy example.
* See: https://bugs.adobe.com/jira/browse/FP-34
*
* Originally by Tox Coxen - http://flashquartermaster.com
* Slight modifications by Dan - http://thewebpageofdan.com
*/</span>
<span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">TimerEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">Timer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getTimer</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TimerTest extends <span style="color: #004993;">MovieClip</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _start<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span>;
   		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _desiredDelay<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1000</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> TimerTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span>_desiredDelay<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">TimerEvent</span>.<span style="color: #004993;">TIMER</span>, tick<span style="color: #000000;">&#41;</span>;
			_start = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> tick<span style="color: #000000;">&#40;</span>evt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TimerEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Timer</span> = <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span>evt.<span style="color: #004993;">currentTarget</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> elapsed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> _start<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> desiredElapsed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">timer</span>.<span style="color: #004993;">currentCount</span> <span style="color: #000000; font-weight: bold;">*</span> _desiredDelay<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = elapsed <span style="color: #000000; font-weight: bold;">-</span> desiredElapsed;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">offset</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;MORE THAN A SECOND OFF!&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Tick | Count: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">timer</span>.<span style="color: #004993;">currentCount</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot; / desired Elpased millis &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> desiredElapsed <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot; / getTimer() elapsed millis: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> elapsed <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot; / offset: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">offset</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Here are the results I get from running it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;">Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">1000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1059</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">59</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">2000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">2112</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">112</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">3</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">3000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">3175</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">175</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">4</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">4000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">4247</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">247</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">5</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">5000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">5311</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">311</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">6</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">6000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">6390</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">390</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">7</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">7000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">7463</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">463</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">8</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">8000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">8511</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">511</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">9</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">9000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">9559</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">559</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">10</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">10000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">10607</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">607</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">11</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">11000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">11671</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">671</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">12</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">12000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">12687</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">687</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">13</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">13000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">13689</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">689</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">14</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">14000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">14759</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">759</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">15</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">15000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">15767</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">767</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">16</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">16000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">16823</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">823</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">17</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">17000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">17871</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">871</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">18</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">18000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">18918</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">918</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">19</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">19000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">19927</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">927</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">20</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">20000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">20983</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">983</span>
MORE THAN A SECOND OFF<span style="color: #000000; font-weight: bold;">!</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">21</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">21000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">22038</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1038</span>
MORE THAN A SECOND OFF<span style="color: #000000; font-weight: bold;">!</span>
Tick | Count<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">22</span> <span style="color: #000000; font-weight: bold;">/</span> desired elapsed millis <span style="color: #000000; font-weight:bold;">22000</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> elapsed millis<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">23119</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #004993;">offset</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">1119</span></pre></td></tr></table></div>

<p>Basically, what this demonstrates, is that as the Timer class &#8220;ticks&#8221; it becomes more and more inaccurate.  Personally, I think this is unacceptable because of how misleading this is to Flash developers using ActionScript 3.0.  Luckily, Tom posted an ActionScript class with his bug report to use as a workaround.  A modified version, which I now use on all my Flash projects that require a &#8220;real&#8221; timer, is posted below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* Workaround for Timer offsets
* See: https://bugs.adobe.com/jira/browse/FP-34
*
* Originally by Tox Coxen - http://flashquartermaster.com
* Edited by Dan - http://thewebpageofdan.com
*/</span>
<span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">Timer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getTimer</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TimerReal extends <span style="color: #004993;">Timer</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _desiredDelay<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _initStart<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
   		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _stop<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
   		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _start<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
   		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _pauses<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _offset<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
&nbsp;
		<span style="color: #3f5fbf;">/**
		* Constructs a new RealTimer object with the specified &lt;code&gt;delay&lt;/code&gt; and &lt;code&gt;repeatCount&lt;/code&gt; states. 
		* 
		* @param delay		The delay between timer events, in milliseconds. 
		* @param repeatCount	Specifies the number of repetitions. If zero, the timer repeats infinitely. If nonzero, the timer runs the specified number of times and then stops. 
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> TimerReal<span style="color: #000000;">&#40;</span><span style="color: #004993;">delay</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, <span style="color: #004993;">repeatCount</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			_desiredDelay = <span style="color: #004993;">delay</span>;
			_initStart = 0;
			_start = 0;
			_stop = 0;
			_pauses = 0;
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">delay</span>, <span style="color: #004993;">repeatCount</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* Manages the timer drift and accounts for pauses caused by stopping and starting the Timer.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> adjustDelay<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Aggregate pauses.</span>
			<span style="color: #009900;">// When start and stop are called internally in flash.utils.Timer _start will equal _stop</span>
			_pauses <span style="color: #000000; font-weight: bold;">+</span>= _start <span style="color: #000000; font-weight: bold;">-</span> _stop;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> elapsed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> _initStart<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> _pauses;
			<span style="color: #6699cc; font-weight: bold;">var</span> desiredElapsed<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">currentCount</span> <span style="color: #000000; font-weight: bold;">*</span> _desiredDelay<span style="color: #000000;">&#41;</span>;
			_offset = elapsed <span style="color: #000000; font-weight: bold;">-</span> desiredElapsed;
			<span style="color: #6699cc; font-weight: bold;">var</span> newDelay<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = _desiredDelay <span style="color: #000000; font-weight: bold;">-</span> _offset;
&nbsp;
			<span style="color: #009900;">// Setting negetive values for delay will cause an error</span>
			<span style="color: #004993;">delay</span> = <span style="color: #000000;">&#40;</span>newDelay <span style="color: #000000; font-weight: bold;">&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> newDelay <span style="color: #000000; font-weight: bold;">:</span> _desiredDelay;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* @private
		*/</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Set _initStart once only otherwise set a value for when Timer.start() is called</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_initStart == 0<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				_initStart = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">else</span>
			<span style="color: #000000;">&#123;</span>
				_start = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span>.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* @private
		*/</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Only set the stop value if the Timer has been started and needs to be stopped i.e. is running</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_initStart <span style="color: #000000; font-weight: bold;">!</span>= 0 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">running</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				_stop = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span>.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* @private
		*/</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_initStart = 0;
			_start = 0;
			_stop = 0;
			_pauses = 0;
			<span style="color: #0033ff; font-weight: bold;">super</span>.<span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* The desired delay.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> desiredDelay<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_desiredDelay = <span style="color: #004993;">value</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* The current offset.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">offset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _offset;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>This class keeps track of how much &#8220;real&#8221; time is passing while the timer is running by using the <code>getTimer()</code> function.  The <code>adjustDelay()</code> method computes the offset and adjusts the <code>delay</code> property.  Here is an example of how you could use the class:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* TimerReal example.
* By Dan - http://thewebpageofdan.com
*/</span>
<span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">TimerEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">Timer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getTimer</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TimerRealExample extends <span style="color: #004993;">MovieClip</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> TimerRealExample<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000000; font-weight: bold;">:</span>TimerReal = <span style="color: #0033ff; font-weight: bold;">new</span> TimerReal<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">TimerEvent</span>.<span style="color: #004993;">TIMER</span>, tick<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">timer</span>.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> tick<span style="color: #000000;">&#40;</span>evt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TimerEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			TimerReal<span style="color: #000000;">&#40;</span>evt.<span style="color: #004993;">currentTarget</span><span style="color: #000000;">&#41;</span>.adjustDelay<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> timeStr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = millisToTimeStr<span style="color: #000000;">&#40;</span>evt.<span style="color: #004993;">target</span>.<span style="color: #004993;">currentCount</span> <span style="color: #000000; font-weight: bold;">+</span> evt.<span style="color: #004993;">target</span>.<span style="color: #004993;">offset</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">//trace(timeStr);</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		* Converts milliseconds to a time string
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> millisToTimeStr<span style="color: #000000;">&#40;</span><span style="color: #004993;">milliseconds</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">seconds</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">milliseconds</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">minutes</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">seconds</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">hours</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">minutes</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> lminutes<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">minutes</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">hours</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> lseconds<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">seconds</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">minutes</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> lmilliseconds<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">milliseconds</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">seconds</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">100</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> millisecondsStr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #000000;">&#40;</span>lmilliseconds <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>lmilliseconds<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> lmilliseconds;
			<span style="color: #6699cc; font-weight: bold;">var</span> secondsStr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #000000;">&#40;</span>lseconds <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>lseconds<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> lseconds;
			<span style="color: #6699cc; font-weight: bold;">var</span> minutesStr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #000000;">&#40;</span>lminutes <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>lminutes<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> lminutes;
			<span style="color: #6699cc; font-weight: bold;">var</span> hoursStr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">hours</span> <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">hours</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">hours</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">hours</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> hoursStr <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;:&quot;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> minutesStr <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;:&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> secondsStr <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;.&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> millisecondsStr<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>If anyone dives deeper into this, let me know what you find!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/11/01/actionscript-timer-class-seem-offset-inaccurate-way-off-it-is/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wordpressified</title>
		<link>http://www.thewebpageofdan.com/2008/10/02/wordpressified/</link>
		<comments>http://www.thewebpageofdan.com/2008/10/02/wordpressified/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 05:01:46 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/?p=157</guid>
		<description><![CDATA[Today I finished putting my entire portfolio in Wordpress, so I thought it would be appropriate to write about my experience setting it up and using it.
I was interested in using Wordpress as a CMS for some time now, mostly because I wanted to be able to edit my portfolio anywhere from a web interface [...]]]></description>
			<content:encoded><![CDATA[<p>Today I finished putting my entire portfolio in <a href="http://wordpress.org">Wordpress</a>, so I thought it would be appropriate to write about my experience setting it up and using it.</p>
<p>I was interested in using Wordpress as a <acronym title="Content Management System">CMS</acronym> for some time now, mostly because I wanted to be able to edit my portfolio anywhere from a web interface and allow people to comment on all of my work in an open format.  In addition, I was looking forward to Wordpress automatically taking care of a number of things I would normally have to do manually like organizing my content and setting up permalinks.<br />
<span id="more-157"></span><br />
I got a basic installation of Wordpress running with a customized theme pretty quickly, and after messing with some of the settings I had it doing everything I needed it to do.  With the help of plugins, I was able to get Wordpress to do more advanced tasks such as optimizing my pages for search engines and automatically creating a sitemap for search engines when updates are made.</p>
<p>Although I find Wordpress a very useful tool that is easy to use and learn, it has its problems.  Here are just a few I ran into:</p>
<ul>
<li><strong>Why can&#8217;t I edit the order of my links?</strong>
<p>This seems ridiculous that without the help of <a href="http://wordpress.org/extend/plugins/my-link-order/">a certain plugin</a> I am forced to list links on the sidebar in alphabetical order. Come on Wordpress!</p>
</li>
<li><strong>No &lt;span&gt; elements within &lt;li&gt; elements.</strong>
<p>In order to style menu lists (like the navigation and sidebar links) the way I wanted with <acronym title="Cascading Style Sheets">CSS</acronym>, I had to install <a href="http://wordpress.org/extend/plugins/list-pages-plus/">yet another plugin</a> to add &lt;span&gt; elements within &lt;li&gt; elements for page links in the navigation menu.  And to add them to link lists on the sidebar I had to manually edit code in two files (not good).</p>
</li>
<li><strong>The <acronym title="What You See Is What You Get">WYSIWYG</acronym> editor messes with <acronym title="HyperText Markup Language">HTML</acronym> code.</strong>
<p>While editing, Wordpress&#8217;s standard editor will automatically add line breaks and remove <acronym title="HyperText Markup Language">HTML</acronym> elements without content, <em>even if you are in the <acronym title="HyperText Markup Language">HTML</acronym> tab of the editor.</em>  This is fine for users who mostly use Wordpress as a blog and write simple content, but it makes things very difficult for more advanced users who run Wordpress as a <acronym title="Content Management System">CMS</acronym> and write <acronym title="HyperText Markup Language">HTML</acronym> code in the editor for some of their pages.  Although I chose to simply disable the <acronym title="What You See Is What You Get">WYSIWYG</acronym> editor in my user preferences, there must be a better solution to this.</p>
</li>
<li><strong>The blog menu link only highlights on the main page of the blog.</strong>
<p>When you go deeper into the blog, like viewing a specific post, the blog list element does not have the appropriate <acronym title="Cascading Style Sheets">CSS</acronym> classes applied to it to allow it to be highlighted.</p>
</li>
</ul>
<p>But enough complaining, here are the plugins that I installed to get my Wordpress installation exactly how I needed it and overcoming some of these problems:</p>
<ul>
<li><strong><a href="http://wordpress.org/extend/plugins/all-in-one-seo-pack/">All in One SEO Pack</a></strong> - Everything you need to optimize your Wordpress installation for search engines.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/cforms/">cforms</a></strong> - What I use to create <a href="http://thewebpageofdan.com/contact/">my contact form</a>, but is capable of adding more complex forms to any Wordpress pages/posts.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/exec-php/">Exec-PHP</a></strong> - Necessary if you need to use <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> code within your pages/posts, like how I grab high scores for <a href="http://thewebpageofdan.com/portfolio/tetris/">Tetris</a>.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/google-analyticator/">Google Analyticator</a></strong> - Adds Google Analytics code to the footer of your templates, which is much nicer than manually adding the code to the footer file.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/google-sitemap-generator/">Google <acronym title="eXtensible Markup Language">XML</acronym> Sitemaps</a></strong> - Automatically generates a <a href="http://thewebpageofdan.com/sitemap.xml">sitemap.xml file</a> for your website (sweet!).</li>
<li><strong><a href="http://wordpress.org/extend/plugins/list-pages-plus/">List Pages Plus</a></strong> - Allows you to make additions to the classes, title, and elements surrounding page links in the navigation menu.  I use this to wrap page names in &lt;span&gt; elements.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/my-link-order/">My Link Order</a></strong> - Let&#8217;s the user decide the ordering of links on the sidebar instead of having them automatically listed alphabetically.</li>
<li><strong><a href="http://wordpress.org/extend/plugins/wordpress-thread-comment/">Wordpress Thread Comment</a></strong> - This plugin allows users to reply to each others&#8217; comments on posts/pages. Personally, I think this functionality should be included in the default Wordpress installation.</li>
</ul>
<p>It was tough getting everything set up, figuring out how all the settings work, and deciding what plugins I needed, but I&#8217;m very pleased with how my site is running in Wordpress and look forward to being able to edit everything within it.</p>
<p><em>Side note</em>: I&#8217;m hoping to use this blog more often to write articles about my experience as a web developer as opposed to mostly using it to announce when I complete projects, so expect to see some useful stuff written here (if I ever get around to it).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/10/02/wordpressified/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash Help Book Creator</title>
		<link>http://www.thewebpageofdan.com/2008/06/23/flash-help-book-creator/</link>
		<comments>http://www.thewebpageofdan.com/2008/06/23/flash-help-book-creator/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 18:13:18 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Flash/ActionScript]]></category>

		<category><![CDATA[Portfolio updates]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/news/?p=13</guid>
		<description><![CDATA[Flash Help Book Creator is a tool to create a Flash extension for an ActionScript library that adds a help book to Flash Help and adds syntax highlighting and code hints to the editor. It started out as something solely for the Sandy 3D engine, but I decided to make it public since it&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thewebpageofdan.com/portfolio/flash-help-book-creator/">Flash Help Book Creator</a> is a tool to create a Flash extension for an ActionScript library that adds a help book to Flash Help and adds syntax highlighting and code hints to the editor. It started out as something solely for the <a href="http://www.flashsandy.org">Sandy 3D engine</a>, but I decided to make it public since it&#8217;s a helpful application that others may find useful.  If you have an ActionScript library that you support, this is what will integrate your code into the Flash <acronym title="Integrated Development Environment">IDE</acronym>. So be sure to give it a try.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/06/23/flash-help-book-creator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WebDevPage: A helpful page for web developers</title>
		<link>http://www.thewebpageofdan.com/2008/05/27/webdevpage-a-helpful-page-for-web-developers/</link>
		<comments>http://www.thewebpageofdan.com/2008/05/27/webdevpage-a-helpful-page-for-web-developers/#comments</comments>
		<pubDate>Tue, 27 May 2008 15:21:16 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Portfolio updates]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/news/?p=12</guid>
		<description><![CDATA[I decided to make WebDevPage public.  It is something I&#8217;ve used for a while for determining information about users&#8217; browsers and installed plugins.  To make it more useful to the public, I added a listing of links that I have found as useful web development resources.  Let me know if there are any problems with [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to make <a href="http://www.thewebpageofdan.com/portfolio/webdevpage/">WebDevPage</a> public.  It is something I&#8217;ve used for a while for determining information about users&#8217; browsers and installed plugins.  To make it more useful to the public, I added a listing of links that I have found as useful web development resources.  Let me know if there are any problems with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/05/27/webdevpage-a-helpful-page-for-web-developers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Virtual cube</title>
		<link>http://www.thewebpageofdan.com/2008/05/21/virtual-cube/</link>
		<comments>http://www.thewebpageofdan.com/2008/05/21/virtual-cube/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:39:50 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Flash/ActionScript]]></category>

		<category><![CDATA[Games/Puzzles]]></category>

		<category><![CDATA[Portfolio updates]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/news/?p=11</guid>
		<description><![CDATA[Virtual cube is something I finished a little while ago and have been revisiting every now and then, but I think it&#8217;s time to finally post it.
The application is a virtual cube (basically a Rubik&#8217;s cube).  It displays a cube that the user can manipulate by rotating both the cube itself and its different [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thewebpageofdan.com/portfolio/virtual-cube/">Virtual cube</a> is something I finished a little while ago and have been revisiting every now and then, but I think it&#8217;s time to finally post it.</p>
<p>The application is a virtual cube (basically a Rubik&#8217;s cube).  It displays a cube that the user can manipulate by rotating both the cube itself and its different levels.  I have included support for different cube sizes and a few different scramble methods.</p>
<p>Currently the &#8220;solver,&#8221; it&#8217;s fake <img src='http://www.thewebpageofdan.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .  It simply retraces the rotations of the user (as well as the scrambler) to return the cube to its solved state.  I know someone who is making a solver that will solve any size cube (NxNxN) in Java, which I will port to ActionScript and incorporate in this application.  This will also allow me to make a feature where the user can &#8220;paint&#8221; the cube by individually placing the stickers on the cube since the solver will then be able to solve a cube without needing to know the rotations it takes to get to that permutation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/05/21/virtual-cube/feed/</wfw:commentRss>
		</item>
		<item>
		<title>An update?!</title>
		<link>http://www.thewebpageofdan.com/2008/05/20/an-update/</link>
		<comments>http://www.thewebpageofdan.com/2008/05/20/an-update/#comments</comments>
		<pubDate>Tue, 20 May 2008 21:22:21 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Portfolio updates]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/news/?p=10</guid>
		<description><![CDATA[It almost took a year, but here I am, alive and posting.  School is out now, so I will be cleaning up my portfolio and posting some of the things I&#8217;ve been working on.  Some of them are already up and running online, let me know if there are problems. 
]]></description>
			<content:encoded><![CDATA[<p>It almost took a year, but here I am, alive and posting.  School is out now, so I will be cleaning up my portfolio and posting some of the things I&#8217;ve been working on.  Some of them are already up and running online, let me know if there are problems. <img src='http://www.thewebpageofdan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2008/05/20/an-update/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New game: Tetris</title>
		<link>http://www.thewebpageofdan.com/2007/08/11/new-game-tetris/</link>
		<comments>http://www.thewebpageofdan.com/2007/08/11/new-game-tetris/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 02:36:59 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
		
		<category><![CDATA[Flash/ActionScript]]></category>

		<category><![CDATA[Games/Puzzles]]></category>

		<category><![CDATA[Portfolio updates]]></category>

		<guid isPermaLink="false">http://www.thewebpageofdan.com/news/2007/08/11/new-game-tetris/</guid>
		<description><![CDATA[Tetris is one of those games that I just had to make&#8230;because I can&#8230;and I did! I tried putting in a few different game modes and will probably add some more in the future as well as more challenges.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://thewebpageofdan.com/portfolio/tetris/">Tetris</a> is one of those games that I just had to make&#8230;because I can&#8230;and I did! I tried putting in a few different game modes <span style="text-decoration: line-through;">and will probably add some more in the future as well as more challenges</span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebpageofdan.com/2007/08/11/new-game-tetris/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
