Including a Timer
Posted: Thu Dec 13, 2012 3:50 pm
Hi,
I am using the "send" command to run a little timer (counting from 60 down
to 0) as follows:
on openCard
put empty into field id 1008
put 60 into timer
put false into halt
updateTimer
end openCard
on mouseDown
put timer into field id 1008
if the mouseLoc is within the rectangle of button id 1012 then answer
"hello"
end mouseDown
on updateTimer
if halt = false then
put timer into field "timer"
put timer - 1 into timer
if timer < 0 then put true into halt
if halt = false then send "updateTimer" to me in 1 second
end if
end updateTimer
This makes updateTimer unpleasantly recursive but anyway...
The value of the timer is available within the card script that contains the
handler "updateTimer" but I would like
A) the timer to run smoothly when other events occur (in this case,
mouseDown) and
B) to be able to access the value of timer from other objects e.g. buttons
on the same card or on other cards. In essence, I want to run concurrent
processes as you can in Scratch. Is there a way of doing this in LiveCode
without it getting unreasonably complicated?
Here's hoping you can help.
I am using the "send" command to run a little timer (counting from 60 down
to 0) as follows:
on openCard
put empty into field id 1008
put 60 into timer
put false into halt
updateTimer
end openCard
on mouseDown
put timer into field id 1008
if the mouseLoc is within the rectangle of button id 1012 then answer
"hello"
end mouseDown
on updateTimer
if halt = false then
put timer into field "timer"
put timer - 1 into timer
if timer < 0 then put true into halt
if halt = false then send "updateTimer" to me in 1 second
end if
end updateTimer
This makes updateTimer unpleasantly recursive but anyway...
The value of the timer is available within the card script that contains the
handler "updateTimer" but I would like
A) the timer to run smoothly when other events occur (in this case,
mouseDown) and
B) to be able to access the value of timer from other objects e.g. buttons
on the same card or on other cards. In essence, I want to run concurrent
processes as you can in Scratch. Is there a way of doing this in LiveCode
without it getting unreasonably complicated?
Here's hoping you can help.