ReviewMyElearning.com

Short ActionScript snippet to count down time

Not much to see here...
A friend asked for a snippet of code to count down mins:secs

var interval:Number
var seconds = 90; // one min and 30 secs

function countDown() {
seconds--
mins = Math.floor( seconds / 60 ) //calc mins left
//calc secs left and stick a 0 in if less then 10 (prettier)
secs = seconds % 60 < 10? 0 + "" + seconds % 60:seconds % 60
if (seconds == 0) {//stop timer if done
clearInterval(interval)
}
trace( mins + ":" + secs ); //do something with output
}
//call our function every second
interval = setInterval(countDown,1000)

Comments

Thanks again James!

I got this to work when a user hits a the video play button. Trying to get it to reset when the user hits the stop button, too.

Before you say it, yes I used the FLVPlayback component and everything works fine, but it seems with Articulate using that component you need the absolute path to the .flv. Works fine but if you upload the package to a webserver, you need to go back in Flash and reset the path to its final resting place.

At my novice level...that's all I know :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may use <swf file="song.mp3"> to display Flash files inline
  • Twitter-style @usersnames are linked to their Twitter account pages.
  • Twitter-style #hashtags are linked to search.twitter.com.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
       _  _  _                        _  _  _  _                           _           _    
(_)(_)(_) (_)(_)(_)(_) _ (_) (_)
(_) _ _ _ _ (_) (_) _ _ _ (_) (_)
(_) (_)(_)(_)(_)_ (_) _ _ _ (_) _(_)(_)(_) (_)_ _(_)
(_) (_) (_) (_)(_)(_)(_) (_) (_) (_)
_ (_) (_) (_) (_) (_) _ (_) (_) (_)
(_) _ (_) (_) (_) (_) (_) _ (_)_ _ _ (_)_(_)
(_)(_)(_) (_) (_) (_) (_) (_)(_)(_) (_)

Enter the code depicted in ASCII art style.