1. Home
  2. Computing & Technology
  3. Animation

Flash Digital Clock

By , About.com Guide

7 of 10

I’ve created a new variable named clocktime, and told Flash that clocktime is equal to the fetched value of the system time’s hours, minutes, and seconds, separated by a colon:

onClipEvent (enterFrame) {
myclock=new Date() ;
clocktime = ((myclock.getHours())+ ":" + (myclock.getMinutes()) + ":" + (myclock.getSeconds())) ;
}

This is very similar to what we did with the date in the Basic Date Functions lesson. getHours( ) retrieves the hours in 24-hour time (values from 0 to 24) ; getMinutes( ) retrieves the current minutes; getSeconds( ) retrieves the current seconds. All of this is based on the system time on the current user’s computer. For instance, as I was testing this, the clock that I viewed said 21:32 (9:32 p.m.) ; at the same time I IMed the URL to the exact same SWF file to a friend in Lancaster, UK, and his read 3:35 (as he’s six hours ahead of me, and apparently his computer’s a few minutes off).

Using + ties everything together into a single string, and placing the colons inside quotations (“:”) tells Flash to display them as actual text rather than reading them as operators/code.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Flash Digital Clock

©2009 About.com, a part of The New York Times Company.

All rights reserved.