Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
From the author of

Using setInterval to Update the Clocks

Trying to set 26 analogue clocks every frame would likely bring your processor to its knees. For this reason, you're only going to set them about once a minute. To do this, you're going to use a really useful new command called setInterval(). It takes two parameters: The first is a function to call (in this case, the brand-new setClocks() routine), and the second is a period in milliseconds. Once set, the named function will be called at the end of every period cycle.

  1. Add this code to the end of the function definition section in the onClipEvent(load) section and save your ActionScript file:

    // Draw map clocks every minute
    setInterval(setClocks(), 60 * 1000);
  2. Return to the Flash MX authoring environment and test the Flash movie for the last time.

    You'll notice that the clocks along the bottom of the map are now all being set correctly. Congratulations, you made it!


    This application only attempts to display time zone offsets. It makes no attempt to compensate for DST within each region to show actual local time. Every attempt has been made to ensure that the time zone offsets for each territory are correct, but like everything in life, they are subject to change.

  • + Share This
  • 🔖 Save To Your Account