ahref.com > Guides > Design
Macromedia Flash Tutorial, Part II, Continued
Keeping Accurate Time
The Flash timer's basic timing element is 'Delay - 1 Second', a Movie
Clip that loops about once per second. After each loop of the Delay
Movie Clip (or after roughly each second), a Tell Target is used to implement the '1 Second' Movie Clip.
When the digit in '1 Second' changes from 9 to 0 (or after about ten seconds), it will
implement the '10 Seconds' Movie Clip. It will continue in this way, keeping time by bringing in ever larger movie clips.
This Flash timer is
not very accurate, but it is totally contained in Flash and will work
with every browser with Flash 3. A more accurate Timer can be made by
using JavaScript and Flash Methods. Unfortunately, communication of
FSCommands (commands sent from Flash) and Flash Methods (commands sent
to Flash) require either Live Connect or ActiveX (32-bit only). This means that this method only works with Netscape 3 or later (on Windows 95/98/NT or Power Macintosh) or Internet
Explorer 3 or later (on Windows 95/98/NT).
A more accurate timer can be made by using a JavaScript function, setTimeout('Settime()',1000),
where setTimeout creates a delay of 1000 milliseconds (1 second), and
Settime() is used to increment the timer. Though this is more accurate
than the Movie Clip delay method, it is not perfectly accurate.
The Flash Clock (which keeps accurate time, instead of just recording elapsed seconds) also uses the setTimeout function, but only for
updating the time (approximately 10 times a second). If the load on the
computer delays the JavaScript execution, the correct time will be sent
when JavaScript is again allowed to have processing time. The sample
Flash Clock will display the user's local time based on the time set on
the user's computer. A Flash Clock can also be built based using the
time retrieved from the server.
|