<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The efnx code blog. &#187; frames per second</title>
	<atom:link href="http://efnx.com/tag/frames-per-second/feed/" rel="self" type="application/rss+xml" />
	<link>http://efnx.com</link>
	<description>code. blog.</description>
	<lastBuildDate>Wed, 18 Jan 2012 20:48:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>AS3 &#8211; Calculating true Frames Per Second</title>
		<link>http://efnx.com/as3-calculating-true-frames-per-second/</link>
		<comments>http://efnx.com/as3-calculating-true-frames-per-second/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 19:01:36 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[com.efnx]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[FPS]]></category>
		<category><![CDATA[frames per second]]></category>
		<category><![CDATA[Stage.frameRate]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=13</guid>
		<description><![CDATA[I strongly recommend you look at this new version of this class. When coding for Flash based games it&#8217;s important to know how fast your project is running [even if you're not coding games it's good to know whether or not your code is slogging down the player]. Adobe&#8217;s Stage class provides a parameter called [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.efnx.com/?p=55">I strongly recommend you look at this new version of this class.</a> </p>
<p>When coding for Flash based games it&#8217;s important to know how fast your project is running [even if you're not coding games it's good to know whether or not your code is slogging down the player]. Adobe&#8217;s Stage class provides a parameter called &#8220;frameRate,&#8221; which allows you to dynamically get and set the player&#8217;s frame rate. Well, not exactly. It allows you to get and set the player&#8217;s TARGET frame rate, the fact is if the player can&#8217;t perform your code at that frame rate, it won&#8217;t! So how can you find out what the real frame rate is? </p>
<p>I wrote a simple class for this task to use in my project development. It&#8217;s super simple. My class, fpsBox, adds an eventListener to the stage [if you pass the stage as an argument when instantiating the class] or to itself, that triggers every frame and increments a value. A timer is started simultaneously with a repeat cycle of one second. Every second the number of counts counted each frame are displayed in the fpsBox and then averaged in an array of instantaneous values. Don&#8217;t worry, the array never gets past two values, the current average and the instantaneous FPS. Here&#8217;s some usage:</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">efnx</span>.<span style="color: #0066CC;">fps</span>.<span style="color: #006600;">fpsBox</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">fps</span>:fpsBox = <span style="color: #000000; font-weight: bold;">new</span> fpsBox<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">fps</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>That&#8217;s it!</p>
<p><b>What it looks like:</b><br />
<iframe src="http://blog.efnx.com/wp-content/uploads/2007/10/fpsExample.html" width="100%"></iframe><br />
<a href='http://blog.efnx.com/wp-content/uploads/2007/10/fpsExample.swf' title='fpsBox example'>Link to SWF</a></p>
<p><b>Source Code</b><br />
<a href='http://blog.efnx.com/wp-content/uploads/2007/10/blogefnxcom-fpsbox.zip' title='fpsBox Class Source Code'>fpsBox Class Source Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/as3-calculating-true-frames-per-second/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

