
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
372
|
Chapter 13: Movie Clips
Our clock is essentially finished. All that’s left to do is call the updateClock() func-
tion with the following line of code, which refreshes the clock display every 100
milliseconds:
setInterval(updateClock, 100);
Test the movie to see if your clock works. If it doesn’t, compare it to the sample
clock .fla file provided at the online Code Depot, or check your code against
Example 13-7. Updating the clock 10 times per second should create a nice smooth
sweep of the second hand, but it may also be overkill (or a drain on performance of a
larger piece).
Reader Exercise: Modify Example 13-7 to update the clock only once per second,
and add a “tick-tock” sound synchronized with the second hand’s movement (which
should give the illusion of a nice firm snap).
Think of other ways to expand on the clock application: Can you draw the clock
programmatically with the Drawing API? Can you make the clock more portable by
turning it into a component? How about dynamically adding minute and hour mark-
ings on the
clockFace_mc clip? Can you modify it to display different or multiple time
zones? Can you create a stopwatch, complete with a reset button?
Onward!
We’ve come so far that there’s not much more to move on to! Once you understand
objects and movie clips thoroughly,