PDA

View Full Version : loadMovie depending on time of day


astroscout7
09-29-2006, 10:20 PM
Hey Peeps,

I am trying to figure out how to load one of 4 images (morning.jpg, day.jpg, evening.jpg, night.jpg) depending on what time of day it is. I would assume that I need to do something like getTime and then some IF statements... but I haven't used flash too much lately and my brain is not wrapping around this idea.

Anyone have any ideas... or has anyone seen any good tutorials for something like this?

Thanks!

astroscout7
09-29-2006, 10:58 PM
I did some messing around with it and got it to work... At least it seems like it works, I'll have to check it at different times of the day to see what happens!

myDate = new Date();
time = myDate.getHours();
if (time < 1) {
loadMovie("night.jpg","contentMC");
} else if (time < 2){
loadMovie("night.jpg","contentMC");
} else if (time < 3){
loadMovie("night.jpg","contentMC");
} else if (time < 4){
loadMovie("night.jpg","contentMC");
} else if (time < 5){
loadMovie("night.jpg","contentMC");
} else if (time < 6){
loadMovie("morning.jpg","contentMC");
} else if (time < 7){
loadMovie("morning.jpg","contentMC");
} else if (time < 8){
loadMovie("morning.jpg","contentMC");
} else if (time < 9){
loadMovie("morning.jpg","contentMC");
} else if (time < 10){
loadMovie("day.jpg","contentMC");
} else if (time < 11){
loadMovie("day.jpg","contentMC");
} else if (time < 12){
loadMovie("day.jpg","contentMC");
} else if (time < 13){
loadMovie("day.jpg","contentMC");
} else if (time < 14){
loadMovie("day.jpg","contentMC");
} else if (time < 15){
loadMovie("day.jpg","contentMC");
} else if (time < 16){
loadMovie("day.jpg","contentMC");
} else if (time < 17){
loadMovie("day.jpg","contentMC");
} else if (time < 18){
loadMovie("evening.jpg","contentMC");
} else if (time < 19){
loadMovie("evening.jpg","contentMC");
} else if (time < 20){
loadMovie("evening.jpg","contentMC");
} else if (time < 21){
loadMovie("evening.jpg","contentMC");
} else if (time < 22){
loadMovie("night.jpg","contentMC");
} else if (time < 23){
loadMovie("night.jpg","contentMC");
} else if (time < 24){
loadMovie("night.jpg","contentMC");
}

keith30
05-08-2007, 02:04 AM
this source is loading a jpeg and a movie clip?

what is you just wanted to load an external swf?

3 external movies, Example: morning.swf, afternoon.swf and evening.swf

astroscout7
05-08-2007, 05:34 PM
This source is just loading a jpeg, but you can load a swf or a jpeg with loadMovie like so:

loadMovie("day.jpg","content");

OR

loadMovie("day.swf","content");

keith30
05-08-2007, 06:23 PM
thank you

keith30
05-08-2007, 06:26 PM
How would I change the script if I were to make it a Desktop widget and the Main.swf was contstantly running? Is there an interval that checks the time and unloads the current swf and then loads the new swf depending on time of day?

astroscout7
05-08-2007, 06:59 PM
I don't know anything about making a widget... but here are the source files and an example so you can see what I did...

SOURCE:
http://www.circleatseven.com/ALEX/actionscripts_org/time/Flash_Time.zip

SAMPLE:
http://www.circleatseven.com/ALEX/actionscripts_org/time/index.html

Have fun!

keith30
05-08-2007, 07:25 PM
I got your source to work before posting the the samples.
I got it to work perfectly last night.

I was wondering if it constantly fetches the time and updates the load movie or it only fetches the time once?

A widget is easy to make. It is only a projector file that you keep contantly running.

keith30
05-17-2007, 02:53 AM
When this is put up on the server, does it read the server time or does is read the time on the computer of the visitor?