Fade to Black

Date:    Wed, 15 Nov 1995 14:28:48 +0000
From:    Matthew Caldwell <sexkittn@BURN.DEMON.CO.UK>
Subject: Re: Fade to Black

>I recall there being a recent discussion of how to use Lingo to fade to
>black.
Lingo doesn't provide a direct way to do this (of course, that would be too easy). There are two ways I can think of.

You can use an XObject/XCMD/DLL like the GammaFade XObj to do it. This is platform dependent, though.

You can combine puppetsprites and the score. This is a ridiculous process, but it does work (albeit in 256 colour mode only). Here's how:

Set aside an area of the score, say 40 frames, that contains nothing but a long fade to black in the palette channel. At the midpoint (where it's completely black) have a frame script like this:

  on exitFrame
    global gMidPointAction
    do gMidPointAction
  end exitFrame
in the last frame (where it's completely white again), have an exitFrame script like this:
  on exitFrame
    global gReturnTo
    go gReturnTo
  end exitFrame
In order to fade to black anywhere in your movie, do this:
  on fadeToBlack
    global gReturnTo, gMidPointAct
    set gMidPointAct = XXXXX
    set gReturnTo = YYYYY
    repeat with index = 1 to 48
      puppetSprite index, true
    end repeat
    go to ZZZZZ
  end fadeToBlack
XXXXX here is a script that you want to be executed while the movie is blacked out. You don't have to do this, of course, but in most cases you'll be fading out in order to do something behind the scenes, and this is where. Note that this script should probably just call a handler somewhere else, since you can't declare globals in a do.

YYYYY is the label or number of the frame you want to return after you've faded back up. Note that when you get to this frame, all sprites will still be puppeted. This is fine if you puppet everything all the time anyway, but if you actually want to frame to appear onscreen, remember to unpuppet everything as soon as you get there.

ZZZZZ is the label or number of the frame the fade to black sequence starts on.

So what's going on? Fade To Black is only available as an explicit action in the score's palette channel, not as a lingo command. So you actually have to run a section of the score in order to do it. But if you want to do it from lingo, presumably you want to preserve whatever you're doing at the time. Puppeting all sprites prevents them from being changed by the score while you're running the fadeToBlack score segment. The callback in the middle allows you to make the required changes while the screen is blacked-out. At the end, you go back to where you were (or somewhere else appropriate), unpuppet if necessary, and away you go.

I said it was ridiculous.