Countdown Timer help, please? :)
Hello!!
I'm trying to create a countdown widget that counts down to the release date of a product and once the date gets here, the timer gets replaced with text and links that say something along the lines of "available now! buy here: purchase link".
I am posting the AS code and the error I'm getting. Any help you guys can give would be greatly appreciated!! Thanks. :)
Alright here is the action script now:
Code:
import flash.events.Event;
var targetDate:Date = new Date(2014, 3, 29, 0,0,0);
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
var nowDate:Date = new Date();
var ms:Number = targetDate.getTime() - nowDate.getTime();
if(ms<=0)
{
removeEventListener(Event.ENTER_FRAME, loop);
gotoAndStop(2);
return;
}
else
{
var sec:Number = Math.floor(ms/1000);
var min:Number = Math.floor(sec/60);
var hr:Number = Math.floor(min/60);
var day:Number = Math.floor(hr/24);
sec = sec % 60;
min = min % 60;
hr = hr % 24;
daytxt.text = day.toString();
hrtxt.text = (hr < 10) ? "0" + hr.toString():hr.toString();
mintxt.text = (min < 10) ? "0" + min.toString():min.toString();
sectxt.text = (sec < 10) ? "0" + sec.toString():sec.toString();
}
}
and the error I am getting:
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at sweet_fla::MainTimeline/loop()[sweet_fla.MainTimeline::frame1:31]
Any help you can give?