Flash Goddess Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excellent use of time

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Flash Goddess Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
Warangel



Joined: 22 Jul 2002
Posts: 928
Location: Toronto

PostPosted: Thu Aug 08, 2002 4:00 pm    Post subject: Excellent use of time Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Mystique
Moderator


Joined: 23 Jul 2002
Posts: 623
Location: Orlando, FL

PostPosted: Mon Aug 12, 2002 9:02 am    Post subject: Reply with quote

Very Clever!!! Preety cool idea. Not sure how I would impliment it on my site but I can fiqure something out Wink
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Warangel



Joined: 22 Jul 2002
Posts: 928
Location: Toronto

PostPosted: Mon Aug 12, 2002 9:10 am    Post subject: Reply with quote

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. Wink
_________________
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
View user's profile Send private message Visit poster's website MSN Messenger
Evil Edna



Joined: 25 Jul 2002
Posts: 101
Location: UK

PostPosted: Mon Aug 12, 2002 9:37 am    Post subject: Reply with quote

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
View user's profile Send private message
the_other_tanya



Joined: 29 Nov 2002
Posts: 2

PostPosted: Sun Dec 01, 2002 5:12 pm    Post subject: referal from other link Reply with quote

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! Mr. Green .
_________________
Always smile, even when you don't want to!
Back to top
View user's profile Send private message Send e-mail
justins



Joined: 17 Jul 2003
Posts: 2
Location: Goldsboro, NC

PostPosted: Fri Jul 18, 2003 9:09 am    Post subject: Reply with quote

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 Question
Back to top
View user's profile Send private message Send e-mail Visit poster's website
K-dog
Moderator


Joined: 23 Jul 2002
Posts: 772
Location: Toronto, ON

PostPosted: Fri Jul 18, 2003 9:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Flash Goddess Forum Index -> Tutorials All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Google
 




Powered by phpBB © 2001, 2005 phpBB Group