Articles Archive
Articles Search
Director Wiki
 

Spotlights

August 17, 1998
by Pat McClellan

Dear Multimedia Handyman,

I know this is probably stupidly easy, but I can't figure out how to do it. I want to reveal a small part of an image when a spotlight (white dot on a black screen) passes over it. I can do it with a huge black graphic with a white hole and 'background transparent' ink, but it runs too slow to follow the mouse around. If I make a black circle, none of the ink effects can make it work; I assume I'm on the correct path. How do I get this to work?

Dave Solko

Dear Dave,

Media Lab's Effector Set does this extremely well. But, if you're looking for a cheap, unantialiased solution, use the Mask ink effect. Here's how it works.

Start with the castmember you want revealed on the stage -- we'll call this one the "image". The location of this castmember in the cast is important. You'll need to create the Mask castmember and place it in the cast *immediately after* the image castmember. The mask castmember must be a 1-bit graphic -- just black and white. The black part is the part which will reveal the image, so for your "spotlight", you'll need to open the paint window and draw a simple black spot (filled circle) for your mask. Now, choose Modify -> Transform Bitmap..., and then change the color depth to 1-bit.

Now, place the image castmember in your score and set the ink effect to Mask. You should see only the part of the image that would be revealed by the mask image. The registration points between the mask graphic and the image castmember will remain locked to each other, so this is how you adjust which part of the image is revealed.

Note that the mask castmember is not placed in the score at all.

Now comes the tricky part... moving the spotlight around. The key to making this work is that the regPoints of the two castmembers always remain locked to each other. So, to move the "spotlight" around, we'll use Lingo to change the regPoint of the mask castmember. Go into your cast and name the mask image "spot". Now, you can move the regPoint like this:


set the regPoint of member "spot" to ¬
  point(whatever, whatever)

So, if you wanted to tie the spotlight to the cursor, you'd use the mouseH and mouseV to dictate how the regPoint moves. Now, as you may have experienced with adjusting regPoints, the image moves counter to the change in regPoint. For example, if you move the regPoint up and left, your image appears to move down and right. So, you'll need to do a little math to tie the spotlight to the cursor. You'll need to include the stage dimensions, the mouseLoc, and the size of the mask in your calculation.


FollowSpot behavior 
property myMask, stageCenter, maskCenter
on beginSprite me
  set myMask = member "spot"
  set stageWidth = the stageRight - the stageLeft
  set stageHeight = the stageBottom - the stageTop
  set stageCenter = point(stageWidth/2, stageHeight/2)
  set maskHeight = the height of myMask
  set maskWidth = the width of myMask
  set maskCenter = point(maskWidth/2, maskHeight/2)
end 
on prepareFrame me
  set mousePoint = point(the mouseH, the mouseV)
  set the regPoint of myMask to (mousePoint ¬
    - stageCenter) * -1 + maskCenter
end

Now, when I made the demo movie, I discovered some bugs. The spot would follow the cursor to a point, then just stop. So I opened the paint window on the mask and watched while I ran the movie and moved the cursor. The regPoint on the mask image was in fact following the cursor, but this change in regPoint was not being reflected on the stage. Frustrated, I turned the sample movie over to king of bugs, Zav. He diagnosed the problem and came up with this workaround: the dimensions of the mask image need to be at least as large as the (revealed) image castmember.

You're thinking, "Hey, but I don't want my spot light to be that big!". Never fear. Just put a single pixel dot in the top left and bottom right corners of your mask image (equidistant from the center of your spot.) Now, that spot will follow your cursor anywhere!

Then, after getting everything working in the dir, I Shocked the movie so I could post the example here. Guess what... the mask won't move in Shockwave. In fact, even the dir file won't work playing back with Shockwave. We've reported the bug and entered it into the Online Bug Database. For now, I guess this mask will have to be static if you want to Shock your movie.

Good luck with your program.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.