Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsDiscussion Forum → Flash help??
Flash help??
2009-05-29, 1:43 AM #1
hey, one of my friends is trying to program a "countdown" in flash, but he is having trouble.

I dont really know a lot about flash, so I figured I'd check and see if anyone here could help... It seems to be counting UP instead of down...
here is the code..

Code:
this.addEventListener(Event.ENTER_FRAME,EnterFrame );
function EnterFrame(event:Event):void {
    
    
    var today:Date = new Date () ;
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    
    var targetDate:Date = new Date(currentYear,03,01);
    var    targetTime = targetDate.getTime()
    
    
    var timeLeft = currentTime - targetTime
    
    var sec = Math.floor(timeLeft/1000);
    var min = Math.floor(sec/60);
    var hrs = Math.floor(min/60);
    var days = Math.floor(hrs/24);
    sec = String(sec % 60);
    if (sec.length < 2) {
        sec = "0" + sec;
    }
    min = String(min % 60);
    if (min.length < 2) {
        min = "0" + min;
    }
    hrs = String(hrs % 24);
    if (hrs.length < 2) {
        hrs = "0" + hrs;
    }
    days = String(days);
    
    var counter:String = days + ":" + hrs + ":" + min + ":" + sec
    time_txt.text = counter;
}
||||||||||||||||||||
2009-05-29, 5:59 AM #2
I don't know Flash either, but this line:
Code:
var targetDate:Date = new Date(currentYear,03,01);

looks like it's setting the target date to be either 3rd Jan or 1st Mar of this year. Which we are getting further away from. Hence the counting up.
2009-05-29, 6:10 AM #3
Im going to go with what Giraffe said!
[01:52] <~Nikumubeki> Because it's MBEGGAR BEGS LIKE A BEGONI.

↑ Up to the top!