pafruu 0 Posted August 27, 2008 Report Share Posted August 27, 2008 Hello, I want to create a 5 min countdown in actionscript. I've found countdowns that countdown to a specific date. I dont want that. I need only a countdown that starts at 5 minutes and goes to zero.here is a countdown tutorial that i've folllowed, it uses dynamic text that goes to a specific date:this.onEnterFrame = function () { var today:Date = new Date(); var currentYear = today.getFullYear(); var currentTime = today.getTime(); var targetDate:Date = new Date(currentYear,11,25); 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 = min + ":" + sec; time_txt.text = counter;}is there a way to modify it so that I can tell it to start at 5 minutes? Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 27, 2008 Report Share Posted August 27, 2008 Check the getTimer function, it will return the number of seconds (I think) since the movie started. Quote Link to post Share on other sites
pafruu 0 Posted August 28, 2008 Author Report Share Posted August 28, 2008 I'm sorry I'm kind of a n00b when it comes to action script. How will the getTimer function work? Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 28, 2008 Report Share Posted August 28, 2008 It just returns a number and doesn't take any arguments. Hit F1 in Flash and search for getTimer, you'll see examples. Quote Link to post Share on other sites
pafruu 0 Posted August 29, 2008 Author Report Share Posted August 29, 2008 ok I got the timer working in a different way but now I need to control the text size as the 5 min clock starts bold and in a size of aprprox. 50 size, as soon as 4:59 shows up all text format dissapears. What am I missing??here the actionScript:var my_format:TextFormat = new TextFormat();my_format.font = "Helvetica";my_format.size = 50;my_format.bold = true;var start = getTimer();var countdown = "5:00";var textbox = this.createTextField(0,0,250,175,200,300);textbox.variable = "countdown";textbox.textColor = 0x0066cc;textbox.setTextFormat(my_format);var runit = function(){ var diff = (getTimer() - start)/1000; var mins = 4+ - Math.floor(diff/60); var secs = 60 - Math.floor(diff%60); countdown = mins + ":" + secs; if(countdown == "0:00") { trace("time\'s up"); clearInterval(timer); };};var timer = setInterval(runit, 1000); Quote Link to post Share on other sites
pafruu 0 Posted August 29, 2008 Author Report Share Posted August 29, 2008 I actually resolved the solution with dynamic text Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.