Detecting mouseUp messages inside a repeat loop
Date: Fri, 13 Oct 1995 03:12:51 +0100
From: Matthew Caldwell <sexkittn@burn.demon.co.uk>
Subject: Re: Trapping mouseUp in a repeat loop
>Is it possible to detect a
>mouse click during a repeat loop? I have an interactive demo where the
>user is presented two lines. One line remains constant while the other
>line grows or shrinks. The users task is to click a button when the two
>lines are equal in length. I tried to use a repeat loop to animate the
>line growth, but I could not stop the growth until the line went through
>the entire growth animation.
You can check the mouse state while in the loop, rather than getting a
mouse event:
repeat while something
...
if the mouseDown then exit repeat
...
end repeat
the disadvantage of this is that if your looped operation is extremely long
and the user clicks very briefly you may miss it. An alternative is to loop
on the frame rather than in a tight repeat:
global something
on exitFrame
if something then
...
end if
...
go the frame
end exitFrame
on mouseDown
set something = false
end mouseDown
As long as your framerate is set to a reasonable level this should give all
the speed you need.
matt xx
____
\ / Matthew Caldwell <sexkittn@burn.demon.co.uk>
\/ Director FAQ -- ftp://sharedcast.hccs.cc.tx.us/JUST_IN/FAQ_04a.sit