Start, Stop, Continue
Dave Cragg
dcragg at lacscentre.co.uk
Sat Sep 10 05:01:35 EDT 2005
On 9 Sep 2005, at 13:10, Glen Bojsza wrote:
> Hi everyone,
>
> Friday's question is about how to allow a user to start,stop and
> continue a
> multimedia demonstration.
>
> Ther are three buttons.
>
> The Start button on a mouseUp starts to cycle through a list of
> commands
> that move graphics, shows and hides fields etc.
>
> on mouseUp
> hide btn "Start"
> show btn "Stop"
> move grc "node" to 120,120 in 2 seconds
> show fld "explanation"
> wait for 3 seconds
> hide fld "explanation"
> ...
> ...
> ...
> end mouseUp
>
> The Stop button on mouseUp stops the cycle of commands the Start
> button
> launched, hides itself and shows a Continue button.
>
> The Continue button on mouseUp starts the cycle of commands the
> Start button
> initially launched but from where the cylce had been stopped.
>
> This is my foray into multimedia and interaction with Rev so I hope
> the list
> will bear with me... traditionally I have worked on "static" apps.
>
> Any suggestions or reference stacks would be appreciated.
This is an alternative approach to Ken's. It probably involves more
scripting, but it may be more transparent. (And perhaps better for
folks like me who have an irrational aversion to using "do". :-))
Divide all the "steps" in the sequence into separate handlers. For
example, if there are 10 steps, something like this (in the card
script):
on step_1
move .... ## whatever
end step_1
on step_2
hide .... ## whatever
end step_2
##etc...
on step_10
show .... ## whatever
end step_10
## Use script local variables to track the next step, and the
"paused" state.
local sNextStep, sPaused
## Have a nextStep handler which is just a big switch.
on nextStep
if sPaused then exit nextStep
switch sNextStep
case 1
step_1
break
case 2
step_2
break
case 3
step_3
break
## etc.
end switch
add 1 to sNextStep
if sNextStep > 10 then put 1 into sNextStep
send nextStep to me in 10 milliseconds
end nextStep
## handlers for start, stop, and continue
on doStart
hide btn "Start"
show btn "Stop"
put 1 into sNextStep
nextStep
end doStart
on doStop
hide btn "Stop"
show btn "Continue"
put true into sPaused
end doStop
on doContinue
hide btn "continue"
show btn "Stop"
put false into sPaused
nextStep
end doContinue
## then in three buttons
## start button
on mouseUp
doStart
end mouseUp
## stop button
on mouseUp
doStop
end mouseUp
## coninue button
on mouseUp
doContinue
end mouseUp
Cheers
Dave
More information about the use-livecode
mailing list