|
|
|
UpDown Timer
Added on 6/7/1999
|
NOTE: you may want to add a startMovie or endMovie handler which clears the actorList.
property pstartMin
property pstartSec
property pCountUp -- time up (1) or count down (0) (default is down)
property pStopTime -- a switch for the timer
property pSecNow
property pMinNow
on getPropertyDescriptionList
set p_list = [ ¬
#pCountUp: [ #comment: "Click for count UP:", ¬
#format: #boolean, ¬
#default: 0 ], ¬
#pStartMin: [ #comment: "Starting Minutes:", ¬
#format: #integer, ¬
#default: 0 ,¬
#range: [min:0,max:59]], ¬
#pStartSec: [ #comment: "Starting Seconds:", ¬
#format: #integer, ¬
#default: 0,¬
#range: [min:0,max:59]]¬
]
return p_list
end
on beginSprite me
set pStopTime = FALSE
add the actorList, me
if NOT pCountUp then
set pStartMin = pStartMin - 1
set pStartSec = pStartSec + 60
end if
startTimer
end
on stepFrame me
if NOT pStopTime then
if pCountUp then
countUp me
else
countDown me
end if
end if
end
on countUp me
set secondsElapsed = the timer/60
set pSecNow = secondsElapsed mod 60
set pMinNow = the timer/3600
displayTime me
end
on countDown me
set secondsElapsed = the timer/60
set pSecNow = pStartSec - (secondsElapsed mod 60)
set pMinNow = pStartMin - (the timer/3600)
if pSecNow > 60 then
set pMinNow = pMinNow + 1
set pSecNow = pSecNow - 60
end if
displayTime me
if pMinNow = 0 and pSecNow = 0 then
set pStopTime = TRUE
end if
end
on displayTime me
if pSecNow = 60 then
put pMinNow + 1 & ":00" into showTime
else if pSecNow < 10 then
put pMinNow & ":0" & pSecNow into showTime
else
put pMinNow & ":" & pSecNow into showTime
end if
put showTime into field "timer"
end
|
|