| View previous topic :: View next topic |
| Author |
Message |
Warangel

Joined: 22 Jul 2002 Posts: 928 Location: Toronto
|
Posted: Thu Aug 08, 2002 4:00 pm Post subject: Excellent use of time |
|
|
Found another minute, and was messing around with time in Flash. I know clocks are nice and all, but what's the point? The user can just look at the clock on their computer, or on the wall !!!
So I got to thinking, what if you controlled elements of your movie based on time? Like a nightclub area on your site for your MP3s, but it is only open between 10PM - 2AM???
So I made a clock. Mine is in a town square. There are streetlamps. They come on at 7PM, and go off at 7AM. The sky gets darker as the night goes on, then lighter as dawn approaches. Lots of fun!
So inside my movieclip for the clock, I put this code:
function setTime(){
d = new Date();
thisHour = d.getHours();
if(thisHour >= 19 && thisHour <= 24){
_root.streetlights._visible = 1;
_root.night._alpha = (math.ceil(thisHour*5)-25);
//trace(_root.night._alpha);
}else if(thisHour >= 0 && thisHour <= 7){
_root.streetlights._visible = 1;
_root.night._alpha = 89 - (89 / (math.floor(thisHour)));
//trace(_root.night._alpha);
}else {
_root.streetlights._visible = 0;
_root.night._alpha = 0;
}
setInterval(setTime,60000);
minutes._rotation=(d.getMinutes()*6)-90;
hour._rotation=((d.getHours())*30)-90;
hour._rotation+=(d.getMinutes()*0.5)
}
setTime();
Now this is MX, but you can use EnterFrame in Flash 5. I just find this takes a lot less system resources.
Download the FLA at
http://www.flashgoddess.com/tutorials/clockMX.fla
Enjoy! _________________ Marcus J. Dickinson
I believe
* do NOT private message me your questions please. Post them on the board, so that all may benefit. Thank you. |
|
| Back to top |
|
 |
Mystique Moderator

Joined: 23 Jul 2002 Posts: 623 Location: Orlando, FL
|
Posted: Mon Aug 12, 2002 9:02 am Post subject: |
|
|
Very Clever!!! Preety cool idea. Not sure how I would impliment it on my site but I can fiqure something out  _________________
 |
|
| Back to top |
|
 |
Warangel

Joined: 22 Jul 2002 Posts: 928 Location: Toronto
|
Posted: Mon Aug 12, 2002 9:10 am Post subject: |
|
|
Thanks. I am actually improving this code. Only need to create the SetInterval once, and some other small edits. Same with the Sound one. Only need to create the object once. Guess I was just really excited.
Having these bizarre dreams of R2D2 recently....go figure.  _________________ Marcus J. Dickinson
I believe
* do NOT private message me your questions please. Post them on the board, so that all may benefit. Thank you. |
|
| Back to top |
|
 |
Evil Edna

Joined: 25 Jul 2002 Posts: 101 Location: UK
|
Posted: Mon Aug 12, 2002 9:37 am Post subject: |
|
|
neat
I was working on a similar idea for my web site (but not as neatly coded).
I have a little cartoon character that is going to be a kind of logo and I want him to be doing different things at different times of the day eg. sleeping, having lunch etc. when people visit.
Ed |
|
| Back to top |
|
 |
the_other_tanya
Joined: 29 Nov 2002 Posts: 2
|
Posted: Sun Dec 01, 2002 5:12 pm Post subject: referal from other link |
|
|
I would like to thank all of you for so many repy's to my time of day question.
The one above (the long one) is almost what I am after but I I dont have street lamps. Great idea though. I wuld like a different movie clip to load insted so instead of seeing a day thingy they would see a night thingy or afternoon thingy or somethingy like that! . _________________ Always smile, even when you don't want to! |
|
| Back to top |
|
 |
justins
Joined: 17 Jul 2003 Posts: 2 Location: Goldsboro, NC
|
Posted: Fri Jul 18, 2003 9:09 am Post subject: |
|
|
Do you all think this would be hard to adapt so their is more than night and day? Say, day, dusk, night, dawn (Dusk with a differant name) and day again?
Take a time laps of the same scene and use those images?
Just checking,
Justin  |
|
| Back to top |
|
 |
K-dog Moderator

Joined: 23 Jul 2002 Posts: 772 Location: Toronto, ON
|
Posted: Fri Jul 18, 2003 9:44 am Post subject: |
|
|
Sure Justin,
You would just need to add more to your if statements pinpointing 'thisHour'. You could have something different for every hour if you wanted.
--K |
|
| Back to top |
|
 |
|