Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is a difference between a <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html" rel="nofollow"><code>Timer</code></a> and using a <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#event%3aenterFrame" rel="nofollow"><code>frame event</code></a> with implications for how the stage is updated, not just on old computers.</p> <p>You can set the suggested frames-per-second settings as part of the <code>.fla</code> file, and the compiled <code>.swf</code> will do its best to keep up with the suggested setting. If it can't, it starts skipping frames to keep up.</p> <p>If you've defined some interactions, such as an animation, to happen on frame events, or via a frame counter, they will execute with the frames, meaning that a higher fps will cause a faster animation. If, instead, the animation relies on a timer, they will execute along with the timer.</p> <p>Executing with a timer will preserve real-time interactions at the cost of some choppiness for animations. A good way to test that you've correctly implemented a timer for an update cycle is to bump the fps down to <code>1</code> or <code>2</code> and see if the animation completes within the same amount of time (&plusmn;1s).</p> <p>As you've tagged <a href="/questions/tagged/game-development" class="post-tag" title="show questions tagged 'game-development'" rel="tag">game-development</a>, I'd recommend using a combination.</p> <p>A cycle using <code>Timer</code> should be used to check input, load resources and check game state (<code>input</code>, <code>load</code>, <code>update</code>)</p> <p>A cycle using <code>ENTER_FRAME</code> should be used to modify drawable assets (<code>render</code>)</p> <p>A cycle using <code>EXIT_FRAME</code> should be used to unload resources (<code>unload</code>);</p> <p>The reason for the combination is that you'll be able to perform the simple calculations on a regular time interval, but you wont waste time with any rendering-specific logic until rendering is actually necessary. Additionally, it will allow your time-critical assets to stay in sync even on slow machines.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload