on scrollUp fieldSprite -- in this case, let's assume we're using an actual live text -- field and scroll up by one line at a time -- get the line height first set theField = the castNum of sprite fieldSprite set myHeight = the textHeight of field theField -- move the sprite up one line set the locV of sprite fieldSprite = (the locV of sprite fieldSprite) - myHeight updateStage end scrollUp
(Obviously in this case the sprites must be puppeted for the changes to be persistent).
This sort of technique has the advantage that it can be used (less the
references
to the textHeight of field, that is) for bitmaps as well,
thereby avoiding the problems with antialiasing and cross-platform
differences discussed here and in
section 17. However, it does place constraints on screen layout, since you need
the masking sprite in front.
An alternative when using bitmaps would be to use the mask ink effect, and
provide a mask bitmap that can substitute for an onstage sprite. In order to do
this, you need to adjust the regPoint of the mask castmember,
while at the same time moving the sprite in the same direction (in effect
the mask provides a
window onto the text):
on scrollUpMask whichSpr, howFarUp -- scrolls a bitmap image of text within a masking "window" -- by a given number of pixels set textImage = the castNum of sprite whichSpr -- when scrolling up, the bitmap must move down, which means -- its regPoint must move up set the regPoint of cast (textImage + 1) = the regPoint of cast (textImage + 1) - point(0, howFarUp) -- adjust the sprite location accordingly set the locV of sprite whicSpr = the locV of sprite whichSpr - howFarUp updateStage end scrollUpMask
Finally, you could simply manipulate the contents of a live text field, so that its contents reflect a small visible portion of a larger actual field. If the display field is of fixed size, it can start off containing the whole text and you only need to delete or replace the first line to scroll the text within it (note that this only works right if there's a return character at the end of each line):
-- this sort of thing can be more easily maintained using objects, -- but let's assume a single source and destination and globals to -- hold everything -- note that we also need the sprite the destination -- field is displaying in, since we need to know its height in order to -- make sure we don't keep going past the end on scrollUpText global gSourceLine, gSourceField, gDestField -- check that we aren't at the top if gSourceLine <= 1 then return -- move the pointer up the source set gSourceLine = gSourceLine - 1 -- copy across the line above, to scroll upwards put line gSourceLine of field gSourceField & return before field gDestField end scrollUpText -- for completeness, here's a corresponding scrollDown script: on scrollDownText global gSourceLine, gSourceField, gDestField, gDestSprite -- check that we aren't at the bottom if gSourceLine > the number of lines in field gSourceField - (the height of sprite gDestSprite / the textHeight of field gDestField) then return -- delete the top line to get it to scroll downwards delete line 1 of field gDestField -- adjust the pointer set gSourceLine = gSourceLine + 1 end scrollDownText
(This isn't an exhaustive list of ways to do this, by any means, just a few examples.)