Count Down Timer
Count Down Timer
(OP)
I found the following code in this forum which displays a count down clock
-- behaviour script attched to a text sprite
on beginSprite me
sprite(me.spriteNum).member.text = "5:00"
startTimer()
end beginSprite
on enterFrame me
tSecElapsed = (the timer)/60
if tSecElapsed < 300 then
tTime = 300 - tSecElapsed
tSec = tTime mod 60
if tSec < 10 then
tSec = "0" & tSec
end if
tMin = tTime/60
sprite(me.spriteNum).member.text = tMin & ":" & tSec
else
sprite(me.spriteNum).member.text = "0:00"
end if
end enterFrame
This obviously works fine but I need one which counts down from 15 seconds (rather than minutes) and have tried changing the code but can't seem to get it to work. Can anyone help?
-- behaviour script attched to a text sprite
on beginSprite me
sprite(me.spriteNum).member.text = "5:00"
startTimer()
end beginSprite
on enterFrame me
tSecElapsed = (the timer)/60
if tSecElapsed < 300 then
tTime = 300 - tSecElapsed
tSec = tTime mod 60
if tSec < 10 then
tSec = "0" & tSec
end if
tMin = tTime/60
sprite(me.spriteNum).member.text = tMin & ":" & tSec
else
sprite(me.spriteNum).member.text = "0:00"
end if
end enterFrame
This obviously works fine but I need one which counts down from 15 seconds (rather than minutes) and have tried changing the code but can't seem to get it to work. Can anyone help?
RE: Count Down Timer
The references to '300' means 300 seconds (five minutes), so just change it to 15, where you see 300.
The second change is to change the text inserted into the member in the 'beginsprite' handler, where it says "5:00" you should change it to "0:15".
- Ben
RE: Count Down Timer