View Full Version : The clock man needs a hand.
I am not Jubba
April 10th, 2002, 01:56 PM
I have this code on my MC. I just want to know if what i'm getting is correct. I have this to get the date, day, month, year...you know the drill, but i can only get the complete date to display if I use onClipEvent(load)....(enterFrame) won't work, and i just wanted to make sure there was a reason behind it. Is it because I'm using arrays? check out the code. I do not want to majorly change the code if it can be avoided...
onClipEvent (load){
mon = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Oct","Nov","Dec"];
weekdays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
now = new Date()
day = weekdays[now.getDay()]
month = mon[now.getMonth()]
date = now.getDate()
year = now.getFullYear()
displayDate = month+" "+date+", "+year
displayDay = day
}
ilyaslamasse
April 10th, 2002, 02:40 PM
No idea. I don't understand, here it says ' ' ' ' after the time.
pom 0]
I am not Jubba
April 10th, 2002, 02:52 PM
well this code works for me. But if I put enterFrame it doens't work...i was just wondering.
ilyaslamasse
April 11th, 2002, 02:49 PM
I tried to do it on press, it works the same. Strange strange. Maybe a little bug ??
pom 0]
suprabeener
April 11th, 2002, 07:53 PM
when you say:
date = now.getDate()
you're overwriting the Date Object. then then next time you go
now = new Date();
it doesn't work.
it's not that it won't work in an onClipEvent(enterFrame), it's that it won't work more than once.
you should really use two events here. use the load event for things that only need happen once:
onClipEvent(load){
mon = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Oct","Nov","Dec"];
weekdays = ["Sun","Mon","Tues","Wed","Thu","Fri","Sat"];
now = new Date();
}
and an enterFrame event for the stuff that needs to be continously updated:
onClipEvent(enterFrame){
day = weekdays[now.getDay()];
month = mon[now.getMonth()];
mdate = now.getDate();
year = now.getFullYear();
displayDate = month+" "+mdate+", "+year;
displayDay = day;
}
note that i've changed the variable date to mdate.
mind you, this info only needs to update every 24 hours so your probably safe just putting the whole thing in a load event. ; )
I am not Jubba
April 12th, 2002, 11:46 AM
yeah i was thinking about that, because no one is really going to be looking at the site for a whole day, or at least while it is switching over, but I don't want the code to be wrong. Thanks for spotting the variable. I knew it was something minor.
ilyaslamasse
April 13th, 2002, 08:35 AM
Supra, good to see you.
I was wondering : What do you mean by overwriting the Date Object ??
pom 0]
I am not Jubba
April 13th, 2002, 11:10 AM
where it says
now = new Date()
then i used
date = now.getDate()
i'm pretty sure that it just causes a conflict within the code.
ilyaslamasse
April 13th, 2002, 12:01 PM
Oh, I see. Thanks.
pom 0]
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.