- It Works Like This
- Preparing to Work
- Using #include to Load ActionScript from a Text File
- Running Conditional Code with OnClipEvent
- The Time Zone Button Layer
- Using Functions to Repeat Common Tasks
- Keeping Time with the ActionScript Date Object
- Using Prototype to Extend the Date Object
- Updating in Real Time
- Updating the Mouse Time Zone
- Setting an Analogue Clock
- Setting a Row of Clocks
- Using setInterval to Update the Clocks
- About This Article
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.
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);
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.