Click to See Complete Forum and Search --> : How to make clock on website like sample?


toplisek
02-17-2009, 01:36 AM
How to make clock on website like sample with flash?

mintedjo
02-17-2009, 04:55 AM
You will need:
- a background image for the clock
- a line for the minutes
- a line for the hours
- a line for seconds (if you care about seconds)

Align them all with the center of the background image.
use some kind of flash timeout to trigger a clock update.
Calculate and set the rotation of each line based on the current time (h,m,s respectively)

Easy!

I'm pretty sure if you google you will find tutorials that are actually helpful.

toplisek
02-17-2009, 05:46 AM
Hi, I have code and background image like:


<?php

$myTime = date("h:i:s");
echo "&mytime=$myTime";
readPHP = function(){
this.loadVariables("myTime.php");
}
polling = setInterval(readPHP, 10000);

?>



1. How to set flash timeout to trigger a clock update?
2. Should be bacground of animation changed as Keyframes or it will be moving automatic?

mintedjo
02-17-2009, 07:48 AM
I'm not that good with flash but I can offer a bit of help...
If you tell the flash movie to play in a loop you can update the clock whenever it reaches a particular frame.
You could have 1 frame with a frame rate of 1 fps so the clock updates once every second.
Then on that frame add all your code to update the image of the clock.
You dont need to change the background, you just need to rotate the fingers on the clock.

Some math:

Full circle = 360 degrees or 6.28 radians
Seconds: 60 seconds so you need to divide 360 by 60.
that means that for every second you need to rotate the finger that represents seconds by 6 degrees.
minutes is the same - for every minute rotate the minute finger 6 degrees
There are only 12 hours to a full circle so you could divide 360 by 12 to get 30 degrees for every hour, but if you do this it will only look right for whole hours. Things like 12:30 will look odd because the hour hand will still point exactly to 12. It would be better to rotate by the 30 degrees per hour and then perhaps an additional 5 degrees for every 10 minutes past the hour. That would make it look more accurate.

Anyway, thats just how I would do it. I don't actually have flash so I can't give an example, and I don't know how to write flash code so sorry but thats about all the help I can give. I'm sure you could find some better information than this by googling. :-P