Jump to content

5 min countdown


Recommended Posts

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?

Link to post
Share on other sites

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);

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...