Help - Search - Members - Calendar
Full Version: Flash Countdown
Zymic Webmaster Forums > Web Design & Development > Graphic Design > Animation (Flash, GIFs, etc)
aussiemcgr
I have pretty much figured out how to make a flash countdown to the kickoff of the Steelers Season. However I have a lil prob with the coding. The coding is done in Macromedia Flash 8. Right now, my countdown is set to September 7th 2008 (kickoff date), but I cant figure out how to set it to 1pm. Everything else is working fine rite now, but the actual time is set to 12am, September 7th, 2008. Also, I'm not sure how it reacts in diff timezones or whatever but I want to know if it is possible to set the currentTime and targetTime to EST just incase. Any help is appreciated.

Countdown code:
CODE
this.onEnterFrame = function() {
    
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    
    var targetDate:Date = new Date(currentYear,8,7);
    var targetTime = targetDate.getTime();
    
    var timeLeft = targetTime - currentTime;
    
    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;
}
aussiemcgr
Prob solved.

For those interested in the solution...

CODE
var targetDate:Date = new Date(currentYear,8,7);
    var targetTime = targetDate.getTime();


All I had to do was add +millisecondamount at the end of the line

Final code (for 1pm)
CODE
var targetDate:Date = new Date(currentYear,8,7);
    var targetTime = targetDate.getTime()+46800000;


And now we have a new problem. I've been googling it for several hours now and havent found an answer.

1) I want to add an end message for when it counts down completely. Right now all it does is go into negative numbers.

2) Also, I want to know how to offset the time using getTimezoneOffset so the timer will show the same thing regardless of timezone.

----------------------------------------------------------------------------------------------------------------------


nvr with these aswell. Ive got answers for each.

1)
QUOTE
if (timeLeft < 0){
nextFrame();
}


2)
QUOTE
var today:Date = new Date();
trace(today.getTimezoneOffset());
var currentYear = today.getFullYear();
var currentTime = today.getTime();
trace(currentTime);
currentTime = (currentTime + ((today.getTimezoneOffset() - 360) * 60000));//timezone offset for CST is -360
trace(currentTime);
Monster
aussiemcgr - Tracing helps to check it's value and of course using it's debug.

I am working on a 3D Carousal which I finish but the code is hard code not components that you can purchase. I like to create my own stuff which helps to learn more but also because I am doing a few other things that relates to other components I have created. The flash components that you can purchase are done sloppy including template which to me are the worse coders, so I also create my own templates but rather use Flex which I enjoy much more then Flash. I plan to covert this project I am doing in Flex 3 or 4 and right now I been creating AS and SWF files to load inside flex and I can control it using flex. It's a really cool thing and you may want to consider downloading the updates for flash, flex and Air which provides more neat features like the Flash player 10. BTW it's safe to use the latest flash updates.

Glad you resolve your problem. It's pretty straight forward your codes and simple, nice work.

Monster-


aussiemcgr
QUOTE(Monster @ Aug 16 2008, 10:41 PM) *
Glad you resolve your problem. It's pretty straight forward your codes and simple, nice work.


Well actually, despite how surprised people may be, I'm not a complete idiot.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.