"Rolling Credits" - Stop them and start them again -Wrap-up!

Alan Gayne alanira9 at mac.com
Sun Mar 6 16:03:37 EST 2005


Ken Ray wrote:

> You should just be able to change the PauseResume and rollCredits 
> handlers:
>

Ken,

Your last little tweak did the trick.  Works perfect now.

My sincere thanks to you and Dick for the help.

In case anyone's interested, here's the full code provided by Ken, 
combined with Dick's optimization using the "filter" command.

Nice job guys!
Alan


on mouseUp
   PauseResume
end mouseUp


local maxScroll
constant scrollIncrement = 1
constant frameTime = 25
local sPaused

-- NOTE - you can change the scroll rate to suit, by increasing or 
decreasing 
-- the "constant frameTime "

on startRolling -- begin rolling credits
   put the formattedHeight of me - the height of me \
       - the topMargin of me - the bottomMargin of me \
       into maxScroll -- the most this field can scroll
   put false into sPaused
   send "rollCredits" to me -- triggers the first frame
end startRolling


on rollCredits -- rolls the next bit
   set the vScroll of me to (the scroll of me + scrollIncrement)
   if the vScroll of me < maxScroll then
     -- trigger the next frame:
     send "rollCredits" to me in frameTime milliseconds
   else -- we're done:
     wait for 2 seconds -- to let the user read the last part
     hide me with visual effect dissolve
     set the vScroll of me to zero
     show me with visual effect dissolve
     put "" into sPaused  -- ADD THIS
   end if
end rollCredits


on PauseResume
   if sPaused = "" then   -- ADD THIS
     startRolling  -- ADD THIS
   else  -- ADD THIS
     if sPaused then
       send "rollCredits" to me
     else
       cancelPendingMessages "rollCredits"
       --CancelPending "rollCredits"
     end if
     put not(sPaused) into sPaused
   end if  -- ADD THIS
end PauseResume


on cancelPendingMessages pMessageName
   -- note: empty implies cancel all pending messages
   put the pendingMessages into tPendingMessages
   if pMessageName is not empty then
     filter tPendingMessages with "*," & pMessageName & ",*"
   end if
   repeat for each line tPendingPessage in tPendingMessages
     cancel item 1 of tPendingPessage
   end repeat
end cancelPendingMessages





More information about the use-livecode mailing list