Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Down Timer

Status
Not open for further replies.

JakeDom1

Programmer
Sep 27, 2006
2
0
0
GB
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?
 
There's two separate things you need to change:

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
 
Thought I tried this already but have done it again and it works. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top