Is this possible? Time in Flash

If I wanted to have a simple picture that changed depending on what time it was would this be possible?
Say for instance there was a simple picture of a guy in a bed, if someone looks at the site then Flash could look at the internal clock on the computer and look at what time it was. If it’s in the morning it shows a picture of sun coming through the window, at night it’s dark.

Possible or not?

yes… I’m working on that exact effect now. I’ve a little bit of script that I have to decypher before I’m ready. Thanks for posting this… I hope some of the others have insight into the getDate features… there are a lot of clock functions but I’m painfuly ignorant of how they all work.

So it is possible?

Yeah… but I dont think you want to see this code until I’ve decyphered it. :slight_smile:

I’ll post it anyway for you to look at… it may seem confusing so I’ll try to break it down a little (this date thing still confuses me.)
If if helps at all, the date object in flash is very similar to the date object in Javascript.

here is the code… straight out of the example I’m cutting apart… this is from Macromedia’s Flash 5.0 Developer’s guide.

var myDate=new Date();

//you know how the hour hand doesn’t jump all at once? - it just creeps?

_root.minutos._rotation = myMinutes6+180;
_root.secondas._rotation = mySeconds
_root.horas._rotation = myHours*30 + hourAdjustment + 180;

All of this code is placed on a blank movie clip in the upper corner of the movie.
Then in the middle of the movie are three movie clips named
minutos, secondas, and horas
which are shaped like clock hands.
The first part of the a/s is entirely to get the date out of the computer. The second section is for rotating hands of the clock.
Now right now, I’m having a problem because I really want my time in 24 hour military time so that, like you, I can judge day time vs night time.

I’ve found some action script and it works good, I’ll show you when my server isn’t playing up, I can’t upload it right now.
The time is 24 hours and you can also have the date in full
24 September 2001
or the date in
as well as the time. One problem with the actionscript is that it displays septmebr as 8 instead of 9.

What I want to do is link the picture, it should be simple like:
if time= 01 to 12 (o clock) then play frame 2
if time = 13 to 18 (o clock) then play fram 1

This is not real or anything but would this simplicity be possible??

yes… sounds like you’re already well on your way there.

What I would do is have movie clips which would start or stop dependent upon the time… the picture itself would have to change as well, but I think that the extra elements would be where it counts.
i.e. My reflecting pool has fireflies which come out at dusk, cricket sounds, frog sounds, rain and lightning… ect. dependent upon certain variables…

The complexity of the program is really fun to try to figure out… but it is possible yes.

This is what I’m using for the 24 hour clock, date in the …/…/… form and the full date as 7 September 2001. But for some reason september comes out as 8 instead of 9, why??

onClipEvent (load) {
days = new Array(‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’);
months = new Array(‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’);
timedate = new Date();
onClipEvent (enterFrame) {
hour = timedate.getHours();
minutes = timedate.getMinutes();
seconds = timedate.getSeconds();
todaydate = timedate.getDate();
day = timedate.getDay();
dayname = days[day];
month = timedate.getMonth();
monthname = months[month];
year = timedate.getFullYear();
if (length(minutes) == 1) {
minutes = “0”+minutes;
if (length(seconds) == 1) {
seconds = “0”+seconds;
currenttime = hour+":"+minutes+":"+seconds;
currentdate = todaydate+"/"+month+"/"+year;
fulldate = dayname+" “+todaydate+” “+monthname+” "+year;
delete timedate;
timedate = new Date();

because flash number datatypes for dates start at 0 so make sure to make something that adds 1 to everything just use this (change i to the variable names):


Any more questions I am sure me or definitly upuaut can help!

thanks to both of you. I appreciate the code snippet…

I’m still working on aspects of this project… this helps a lot.