orthopedic pain management

Flashuser

  • Pin It

Tips & Tricks 5: Display digital time

For today’s trick I will show how you can display digital time in Flash.

1. Using the Text Tool(T) create 3 Textboxes(hours, minutes, seconds).

2. Give each one a name in the Var field of the Properties Panel.(for this example I use h – hours, m – minutes, s – seconds).

3. Write the following Actionscript code:

[as3]
var dt
var timeint;

date = new Date();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
timeint = setInterval(displayZ, 1000);

function displayZ() {
date = new Date();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
if (h<10) {
h = "0"+h;
}
if (m<10) {
m = "0"+m;
}
if (s<10) {
s = "0"+s;
}
}
[/as3]

4. If you want to display GMT Time(the example above uses Local Time) replace getHours() with getUTCHours, getMinutes() with getUTCMinutes() and getSeconds() with getUTCSeconds().



Get Adobe Flash player

Author: Alin

Passionate about web and graphic design, photography and climbing. Follow me at Twitter , Facebook and Google+