Checking for Empty Sprite Channels

Date:    Thu, 2 Mar 1995 09:50:06 -0800
From:    David Miller <davem@PANGEA.STANFORD.EDU>
Subject: Puppeting empty sprite channels: a simple handler
Someone somewhere said something about the unrecognized puppeting of empty sprite channels causing problems. I use this simple handler during development to help prevent this. This is probably obvious to alot of people, but I thought I'd post anyway cause I've found it useful.
on PuppetMe mySprite
  if the castnum of sprite mySprite <> 0 then
     puppetsprite mySprite, TRUE
  else
     alert "There is no castmember in channel"&&mySprite&"."
  end if
end


Date:    Sun, 7 May 1995 23:41:00 -0600
From:    Chris Malley <cvm@BHI.COM>
Subject: Re: Puppet without cast in channel

> Roy Pardi notes on April 29, "Didn't realize one could put a cast member on
> stage without there being a placeholder already in the channel. This works."
>
> The problem will later be found to be due to this disregard of the Lingo
> Dictionary's line "The channel must contain a sprite when you use the
> puppetSprite command."
This bit me once a long time ago, so I never directly puppet sprites. I always use the following routine, which prevents me from making this mistake.
-- Puppet a channel only if it's populated.
on safePuppetSprite whichSprite
   if (the castnum of sprite whichSprite = 0) then
       alert "Attempt to puppet unpopulated channel:" && whichSprite
       return
   else
       puppetSprite whichSprite, TRUE
   end if
end
One would think that Director would be smart enough to do something like this itself. But I've seen this pattern before.... :-)