Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

countdown timer 1

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
0
0
AU
Hi,

I am a flash newbie (Programming background - Delphi, VB.NET, ASP) and need some direction with a countdown timer.

I am trying to make a countdown timer based on a date and time. I want it to show days,hours,minutes,seconds like the one on this page
I have found some examples, however most do not enable me to enter the start time/date.

Any help,pointers or websites will be a great help.

Thanks in advance.




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
this is not great coding but something i saved a long time ago....no idea who wrote the code.....can be greatly improved upon

Code:
Say you want to count down till new year 2006..... 

Make a text field and give it variable name "timeRemaining" 
Place it in movie clip and paste the following action to this clip. 
right click on clip - Actions : 


onClipEvent (enterFrame) { 
now = new Date(); 
NEW_YEAR = new Date(2006, 0, 0, 23, 59, 59); 
days = (NEW_YEAR-now)/1000/60/60/24; 
daysRound = Math.floor(days); 
hours = (NEW_YEAR-now)/1000/60/60-(24*daysRound); 
hoursRound = Math.floor(hours); 
minutes = (NEW_YEAR-now)/1000/60-(24*60*daysRound)-(60*hoursRound); 
minutesRound = Math.floor(minutes); 
seconds = (NEW_YEAR-now)/1000-(24*60*60*daysRound)-(60*60*hoursRound)-­(60*minutesRound); 
secondsRound = Math.round(seconds); 
if (secondsRound == 1) {sec = " second ";} else {sec = " seconds "; 


} 


if (minutesRound == 1) {min = " minute ";} else {min = " minutes "; 

} 


if (hoursRound == 1) {hr = " hour ";} else {hr = " hours "; 

} 


if (daysRound == 1) {dy = " day ";} else {dy = " days "; 

} 


timeRemaining = daysRound+dy+hoursRound+hr+minutesRound+min+secondsRound+sec­; 


}
 
Thanks for your help but I am getting some script errors. Will keep trying.




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Got it working, thanks mate.




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
yip just checked it myself.....couple of unwanted - signs in there....works fine with those removed....still a poor piece of code though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top