"Rolling Credits" - Stop them and start them again

Alan Gayne alanira9 at mac.com
Sat Mar 5 09:33:51 EST 2005


Hi all!

I've been using the "recipe" for "rolling credits" (provided in the 
docs) for the main text field in a "Help" stack I'm putting together 
for the application I've been working on.

Works great - and everyone who sees it agrees that it's a real nice 
touch.  You click once on the field and the text scrolls to the end, 
and then resets.

However, I got to thinking, since this is a help stack, my user might 
want to click on the field at some point to stop the scrolling, look at 
something for a while, then click again, to have the scrolling pick up 
again at the same point.

My first thought was that it should be easy to modify the original 
recipe to get this effect.  And maybe it is.  But, after a few 
frustrating hours of no joy, I thought "Hey!  Asking for help is no 
shame", even though I strongly suspect this has a very simple answer.

So, I'm asking for help - humbly, I might add.

Here's the script from the original recipe (so you won't have to look 
it up).
------
local maxScroll
constant scrollIncrement = 1
constant frameTime = 25

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
   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
   end if
end rollCredits

Thanks in advance,
Alan Gayne



More information about the use-livecode mailing list