<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: fps code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 08:01:49 GMT</pubDate>
    <description>DZone Snippets: fps code</description>
    <item>
      <title>Display FPS in Flash Movie</title>
      <link>http://snippets.dzone.com/posts/show/4006</link>
      <description>&lt;code&gt;&lt;br /&gt;_root.createEmptyMovieClip("movFrameRate",100); &lt;br /&gt;&lt;br /&gt;_root.movFrameRate.onEnterFrame = function() { &lt;br /&gt;this.t = getTimer(); &lt;br /&gt;this.frameRate = Math.round(1000 / (this.t - this.o)); &lt;br /&gt;//trace(this.frameRate); &lt;br /&gt;this.o = this.t; &lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 14 May 2007 01:10:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4006</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>Adjust FPS with Actionscript</title>
      <link>http://snippets.dzone.com/posts/show/4004</link>
      <description>&lt;code&gt;&lt;br /&gt;// Usage &lt;br /&gt;&lt;br /&gt;// sets _root.yourMC fps to 100 playing forward, but none of the child mcs, that will stop on the last frame &lt;br /&gt;// _root.yourMC.engineTune(100) &lt;br /&gt;&lt;br /&gt;// sets _root.yourMC fps to 20 playing forward, including the child mcs &lt;br /&gt;// _root.yourMC.engineTune(20, true) &lt;br /&gt;&lt;br /&gt;// sets _root.yourMC fps to 50 playing backward if the currentframe is greater than 20, without altering the child mcs &lt;br /&gt;// _root.yourMC.engineTune(50, false, "down", 20)&lt;br /&gt;&lt;br /&gt;MovieClip.prototype.engineTune = function(fps, inherit, dir, endF) { &lt;br /&gt;   var intv, mc, d, end; &lt;br /&gt;   intv = 1000/fps; &lt;br /&gt;   d = (dir == "down") ? -1 : 1; &lt;br /&gt;   if (!endF) end = (dir == "down") ? 1 : this._totalframes;    &lt;br /&gt;   clearInterval(this.tuneUpID); &lt;br /&gt;   this.tuneUpID = setInterval(fineTune, intv, this, d, this._currentframe, end); &lt;br /&gt;   if (inherit) { &lt;br /&gt;      for (var i in this) { &lt;br /&gt;         if (typeof (this[i]) == "movieclip") { &lt;br /&gt;            clearInterval(this[i].tuneUpID); &lt;br /&gt;            this[i].tuneUpID = setInterval(fineTune, intv, this[i], d, this[i]._currentframe, end); &lt;br /&gt;         } &lt;br /&gt;      } &lt;br /&gt;   } &lt;br /&gt;   function fineTune(mc, d, sf, end) { &lt;br /&gt;      _if = (sf&lt;end) ? mc._currentframe &lt; end : mc._currentframe &gt; end &lt;br /&gt;      if (_if) { &lt;br /&gt;         mc.gotoAndStop(mc._currentframe+d); &lt;br /&gt;      } else { &lt;br /&gt;         clearInterval(mc.tuneUpID); &lt;br /&gt;      } &lt;br /&gt;   } &lt;br /&gt;}; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 14 May 2007 01:07:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4004</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
  </channel>
</rss>
