
Welcome Guest
|
#1
|
|||
|
|||
|
Countdown Timer
Hi,
just want to know if some one can help me with my countdown timer. every time it my countdown timer gets to zero it goes back to 59:59:59:59. i need it to stay at 00:00:00:00 or even better make it flash. Code:
var thisYear:Number = 2011;
var thisDay:Number = 28;
var thisMonth:Number = 2;
var thisHours:Number = 19;
var thisMin:Number = 30;
var thisSec:Number = 0;
var countdownXML:XML = new XML();
countdownXML.ignoreWhite = true;
countdownXML.load( 'countdown.xml' );
countdownXML.onLoad = function( success:Boolean ):Void
{
var nowDate:Date = new Date();
if( success ) {
var eventDateData = countdownXML.childNodes[0].childNodes;
if( eventDateData[0].attributes['year'] ) thisYear = Number( eventDateData[0].attributes['year'] );
if( eventDateData[0].attributes['month'] ) thisMonth = Number( eventDateData[0].attributes['month'] );
if( eventDateData[0].attributes['day'] ) thisDay = Number( eventDateData[0].attributes['day'] );
if( eventDateData[0].attributes['hours'] ) thisHours = Number( eventDateData[0].attributes['hours'] );
if( eventDateData[0].attributes['minutes'] ) thisMin = Number( eventDateData[0].attributes['minutes'] );
if( eventDateData[0].attributes['seconds'] ) thisSec = Number( eventDateData[0].attributes['seconds'] );
var testEventDate = new Date(thisYear, thisMonth-1, thisDay, thisHours, thisMin, thisSec );
if( testEventDate <= nowDate ) {
thisYear = nowDate.getUTCFullYear();
thisDay = nowDate.getUTCDate() + Math.round( Math.random() );
thisMonth = nowDate.getUTCMonth();
thisHours = nowDate.getHours();
thisMin = nowDate.getMinutes();
thisSec = nowDate.getSeconds();
}
} else {
thisYear = nowDate.getUTCFullYear();
thisDay = nowDate.getUTCDate();
thisMonth = nowDate.getUTCMonth();
thisHours = nowDate.getHours();
thisMin = nowDate.getMinutes();
thisSec = nowDate.getSeconds();
}
startCountdown();
}
function startCountdown():Void
{
eventDate = new Date(thisYear, thisMonth-1, thisDay, thisHours, thisMin, thisSec );
this.onEnterFrame = update;
}
function update():Void
{
//Current time
var now:Date = new Date();
var timeLeft:Number = eventDate.getTime() - now.getTime();
//Converting the remaining time into seconds, minutes, hours, and days
var seconds:Number = Math.floor(timeLeft / 1000);
var minutes:Number = Math.floor(seconds / 60);
var hours:Number = Math.floor(minutes / 60);
var days:Number = Math.floor(hours / 24);
//Storing the remainder of this division problem
seconds %= 60;
minutes %= 60;
hours %= 24;
updateCounters( days, hours, minutes, seconds );
}
function updateCounters( numDays, numHours, numMin, numSec ):Void
{
days.gotoAndPlay( 'to' + numDays );
hours.gotoAndPlay( 'to' + numHours );
min.gotoAndPlay( 'to' + numMin );
sec.gotoAndPlay( 'to' + numSec );
}Regards, Adam |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Countdown Timer | adz_aus | Newbies |
2 | 03-18-2011 07:36 PM |
| Countdown Timer help | adiboy | Flash MX ActionScript |
6 | 08-01-2007 07:47 PM |
| Something like a countdown timer | datrademarc | Actionscript 2.0 |
0 | 11-11-2006 07:29 AM |
| Actionscript countdown timer | boing_5000 | Flash MX ActionScript |
0 | 04-28-2004 01:41 PM |
| Countdown Timer | integra | Flash MX ActionScript |
7 | 04-16-2004 09:45 PM |





