|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Countdown
I want to create a countdown .swf file that countsdown to a certain date show days, hours, minutes, and seconds and does all this by accessing a .txt file with the date information.
I have no idea where to start, but I did attach a .fla I got off of Flash Kit that resembles what I want to do, but does not have the date in it and does not connect to a .txt file. Can anyone help me out with this? |
|
#2
|
|||
|
|||
|
I dunno about the fla you have but if you have a textfile that looks like:
Code:
&deadline=25/12/2003 you can load it up and display how lonmg is left like this: Code:
date_lv = new LoadVars();
date_lv.onLoad = parsedate;
date_lv.load("date.txt");
msInDay = 86400000;
msInHour = 3600000;
msInMinute = 60000;
function parseDate(success) {
if(success) {
var d = this.deadline.split("/");//change this according to the format your "date" is in
var deadline = new Date(d[2],d[1],d[0]);
deadline = deadline.getTime();
//trace("deadline:"+deadline);
var now = new Date();
var t = deadline - now;//ms between then and now
//trace("t:"+t);
var daysTilThen = Math.floor(t/msInDay);
var remainder = t-(daysTilThen*msInDay);
//trace("remainder:"+remainder)
var hoursLeftOver = Math.floor(remainder/msInHour);
remainder = remainder-(hoursLeftOver*msInHour);
var minutesLeftOver = Math.floor(remainder/msInMinute);
// then display the results somehow....
trace("Time left til "+this.deadline+": "+daysTilThen+" days, "+hoursLeftOver+" hours, "+minutesLeftOver+" minutes.")
} else {
trace("problems loading date!");
}
}
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Countdown |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|