Another Countdown Timer Question
March 10th, 2010 by janeAll I need is minutes and seconds to display.
This is for timed learning modules.
When the time is up, I would like the movie to proceed to the last frame.
I have found many countdown timer examples online but they typically require a button to start the countdown and an entry of the staring time or they countdown to a date that is entered. These are way too complex for my needs.
I need the timer function to be invisible to the user. Just display how much time is left.
I am new to Flash, and have tried to modify existing codes with terrible results.
Help! cried the newbie.
Visually, it'll get confusing because of how analog clocks work with the 0 in front of numbers less than 10 such as 5:09...so I'm not sure how you'd place a timer so the user can see it, but it can be done visually by seconds rather than mins:seconds with this code:
// Minutes of timer.
var minutes:Number = 5;
// Seconds of timer.
var seconds:Number = 30;
var totalSeconds:Number = (minutes*60)+seconds;
var runCountdown = setInterval(countdownTimer, 1000);
function countdownTimer() {
if (totalSeconds>0) {
totalSeconds--;
}
}
onEnterFrame = function () {
if (totalSeconds<=0) {
clearInterval(runCountdown);
trace("Time's Up!");
// Execute code to progress to last frame here.
delete onEnterFrame;
}
};This code runs for 5mins 30 seconds. Make sure you fill in the minutes/seconds variables & flash should do the rest for you. Also, fill in the code that runs the movie to the end once the time is up.
(oh & thank you anogar, Ive found my first use for using your help lol)
#If you have any other info about this subject , Please add it free.# |
Posted in enart.gcgx.com | edit