Pausing a simple animation

John J. Theobald mailjjt at bellsouth.net
Thu May 15 21:22:01 EDT 2003


Jim Biancolo wrote:

> At 06:24 PM 5/15/2003 -0400, you wrote:
> 
>> Ooops ... my fault.  Let's try that again.  Should have been "without 
>> waiting".
> 
> 
> Ah, gotcha!  Thanks for the follow-up.  Unfortunately I already have 
> "without waiting" in there.  I had (stupidly) snipped it in my first 
> example and represented it with an ellipsis because I didn't think it 
> would be relevant, but I did include it in my second example:
> 
> --- EXAMPLE ---
> When I hit "play" this code runs:
> 
> on mouseUp
>    send animateTokens to card "myCanvas" in 10 milliseconds
> end mouseUp
> 
> This invokes the handler:
> 
> on animateTokens
>   global b_play
>   put TRUE into b_play
>   repeat for each line L in field "frames"
>     set the lockMoves to true
>     repeat with i = 1 to the number of images in group "tokens_group"
>       move image i of group "tokens_group" to coords without waiting
>     end repeat
>     set the lockMoves to false
>     if not b_play then break
>   end repeat
> end animateTokens
> --- /EXAMPLE ---
> 
> With the code above, even with "without waiting", the "pause" button is 
> unclickable until animateTokens completes.  What I want to be able to do 
> is click "pause" and set the global var "b_play" to FALSE, thereby 
> breaking the loop in animateTokens, but I'm good and stuck at the moment.
> 
> Thanks!
> 
> Jim
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 


Jim-

Hmmm, my first inclination is to suspect that it gets through the 

repeat loop faster than you can click the pause button.

For experimentation, throw a "wait 1 second" in the repeat for each line 
L loop and see if that's the problem.


Other things to look at:

b_play may not be getting set to "FALSE" in the pause button handler. 
Or, there is no code to stop the movement.

Is b_play declared in the "pause" button handler as well as a global?

I would test b_play like this:

if b_play is "TRUE" then
     set the lockmoves to false
else
     break
end if


Note that the break merely stops the repeat through the lines of field 
"frames".  It does not stop the movement. If you want to stop the 
movement you will need to add some code to the animateTokens handler or 
the pause button handler.

Does this help any?


John




More information about the use-livecode mailing list