Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Real time light


Gionex
6/10/2004 8:27:21 PM
Hi
What I would like to know is how to programe a light that has 2 frames, 1 that
has nothing and another that has a light. When the time is between 4:00 and
20:00 the light is on frame 1 (switched off) and between 20:00 and 24:00 + 1:00
and 4:00 the light to be on frome 2 (switched on)
cypherdog
6/10/2004 10:45:40 PM
You can do that by putting the 2 frames inside a movieclip.... then drag that
movie clip onto the stage and name it "light"

Now on the movie clip you can have some code like this:
onClipEvent(load){
//create date object
time = new Date();
hours = time.getHours();
}
onClipEvent(enterFrame){
if(hours > 4 && hours < 20){
this.gotoAndStop(1);
}else{
this.gotoAndStop(2);
}
}


Something like that should work well, haven't tried it mind you so it might
have a bug here and there...just let me know how it goes!



Gionex
6/11/2004 8:30:26 AM
Thanks for your help but I have figured it out for myself. Your is a bit
different to mine, but mine works. I have the time vars on the main timeline
and i got something like this in the movie clip:
if (hours = blahblahblah){
nextFrame();
}else{
stop();

Thanks for your help anyway! :)
AddThis Social Bookmark Button