-
junior master chef
finding out the time
hello.
on my site i think it would be nice if when you enter a quick "good morning" "good afternoon" or "good evening" message was displayed. how could i do this? is it possible?
cheers
jh
-
it's very easy.
just use this code:
Code:
myDate = new Date();
trace(myDate.getHours());
.getHours returns a number ranging from 0-23. then base your greeting on the hour.
-
junior master chef
thanks for the quick reply. but still a few problems
what do i add this code too?
how do i get the right greeting for the right hour?
sorry for my dumbness, bit im an animation man, not actionscript.
cheers
jh
-
Senior Member
Let's say you make a movie that has 4 keyframes.
The first one is invisible (has nothing).
The second one says 'good morning'
The third says 'good afternoon'
The fourth says 'good evening'
On the first frame of the movie, add a script that says:
Code:
var myDate = new Date();
var hour = myDate.getHours();
if (hour < 12) {
this.gotoAndStop(2); // morning
}
else if (hour < 12+6) {
this.gotoAndStop(3); // afternoon
}
else {
this.gotoAndStop(4); // evening
}
If you'd like to animate those messages, then add more frames, and fix the frame numbers in this script to match. Also use 'gotoAndPlay' instead of 'gotoAndStop', and fix the sequences to stop at the end (add a 'stop();' on the last frame of each sequence).
Last edited by jbum; 03-14-2004 at 10:31 PM.
-
junior master chef
thats great thanks.
i love you people
-
 Originally Posted by jbum
Let's say you make a movie that has 4 keyframes.
The first one is invisible (has nothing).
The second one says 'good morning'
The third says 'good afternoon'
The fourth says 'good evening'
On the first frame of the movie, add a script that says:
Code:
var myDate = new Date();
var hour = myDate.getHours();
if (hour < 12) {
this.gotoAndStop(2); // morning
}
else if (hour < 12+6) {
this.gotoAndStop(3); // afternoon
}
else {
this.gotoAndStop(4); // evening
}
If you'd like to animate those messages, then add more frames, and fix the frame numbers in this script to match. Also use 'gotoAndPlay' instead of 'gotoAndStop', and fix the sequences to stop at the end (add a 'stop();' on the last frame of each sequence).
Hi there!
I'm also looking for a variation of this.
Except instead of displaying a different frame ccording to the time of day, how would I display a different frame according to the day of week?
Or rather, for a one week period, I would like to display a frame or scene each for Mon-Fri.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|