Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. DHTML Essentials > Timers, Speed, and Frame Rate

Timers, Speed, and Frame Rate

This section deals with programming issues related to throttling graphical updates in JavaScript to give the user an optimal experience. We want graphics that have smooth and fluid movement, and that are neither too quick nor too slow. The performance of the user’s computer will influence how fast moving graphics are updated. I’ll also discuss a solution for reducing these apparent speed variations on different machines.

Using setInterval and setTimeout

JavaScript’s setInterval() and setTimeout() functions allow you to call JavaScript code at regular intervals. Applications that require regular graphical updates, such as arcade games, would be difficult, if not impossible, to write without them.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint