View Full Version : Countdown to Specific Date #2
suzieq
July 1st, 2004, 11:24 AM
Help!
I am trying to countdown to a date next year (2005) and cannot seem to manipulate the code to make it work :) Help!
eventDate = new Date( 2005, 06, 16 , 18 , 0 , 0 , 0);
What am I doing wrong? Please help.
This is Flash MX.
Prophet
July 1st, 2004, 02:11 PM
wats the problem?
wat r u trying to achieve?
a days till countdown?
a days month year countdown?
what other code have you got?
Prophet.
suzieq
July 1st, 2004, 05:44 PM
Hello - the date that I am trying to countdown to is July 16th, 2005...
I would like to do a days, hours, minutes countdown.
The original code from the free countdown.fla file from this site looks like this:
currentDate = new Date();
thisYear = currentDate.getFullYear();
eventDate = new Date(thisYear, 11, 25);
eventMillisecs = eventDate.getTime();
counter.onEnterFrame = function() {
currentDate = new Date();
currentMillisecs = currentDate.getTime();
this.msecs = eventMillisecs-currentMillisecs;
if (this.msecs<=0) {
I replaced the line: eventDate = new Date(2005, 06, 16); , but the countdown is counting down from July 2004, not 2005.
Help?
Prophet
July 1st, 2004, 07:26 PM
erm... ok then...
i will write you a commented code for this for (hopefully) tomoro because it is a bit more complicated than your average countdown (only a bit but it IS 12.30 here!!) i will breadown and explain it to you as well... that is unless some1 beats me to it!! :P
Prophet.
suzieq
July 2nd, 2004, 08:14 AM
Thank you!
I anxiously await your reply!
Prophet
July 2nd, 2004, 02:29 PM
ok i gotta go out tonite an dunno wen ill b bak... :S
so i thout id post this 4 ya... its not 100% commented and isnt 100% accurate when months change... but aint had much time...
itd be a lot easier to just hav it counting down with months as well... but u asked for days... so i will giv u days... just u gotta giv me bit mor time im afraid... :S sorry!!
neway, heres the uncommented half code that will work... ish....
post asap wit proper version 4u...
just set a dynbamic text boxes variable to "StringCD" (without quotes) k?
//Event Date = 16-7-2005
EvenD = 16
EvenM = 7
EvenY = 2005
monthsDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31)//this is an array containing the number of days in each month...
if(StartCount!=false){
CountDown = setInterval(Rem,1000)
StartCount = false
}
function Rem(){
Current = new Date()
CY = Current.getFullYear()
CM = Current.getMonth()+1
CurrD = Current.getDate()
CurrM = Current.getMinutes()
CurrH = Current.getHours()
while(CurrD!=Day){
Day = CurrD
calc = true
}
if(calc == true){
LeftD = 0
LeftMo = 0
if(EvenY == CY){
ML = (EvenM-CM)-1 // calculates number of FULL months remaining when the event year = current year
if(LeftMo <0){
LeftMo = 0
}
}
else{
ML = ((((EvenY-CY)*12)-CM)+EvenM)-1//calculates number of FULL months remaining
}
LeftD = monthsDays[CM]-CurrD
if( CM == EvenM && CY == EvenY){
LeftD = EvenD-CurrD
}
else{
LeftD += EvenD
}
MLa = ML
for(MLb=ML;MLb!=0;MLb--){
MLa ++
if(MLa == 13){
MLa = 1
}
LeftMo+=monthsDays[MLa+1]
trace(MLa)
}
calc = false
LeftD += LeftMo-2
}
LeftM = 60-CurrM
if(LeftM <10){
LeftM = "0"+LeftM
}
LeftH = 23-CurrH
if(LeftH <10){
LeftH = "0"+LeftH
}
StringCD = ""
StringCD = LeftD + " Days, " + LeftH + " Hours, " + LeftM + " Minutes"
} just stick that on the first frame... note you only want to run this script once so u mite wanna add an if(sumVar!=true){....[code above]... ; sumVar = true} in ifu have multiple frames....
sorry i cant givu finished product just yet but i really gtg... :S
Prophet.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.