Kingsley eLearning Solutions

You have big dreams for your eLearning.
We'll make them come true.

image of Kingsley

Short ActionScript snippet to count down time

Submitted by Kingsley 👑 on Thu, 08/12/2010 - 13:04

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

Add new comment

Tags