Director News
Director Web Sites
Mailing Lists
News Groups
Project Examples
Useful Web Sites

Don't miss these
Powerpoint in Director
Set FrameRate of a Animated Gif Cast Member
Change Line Direction of a Shape Cast Member
Calculating the day of the date
Irregular MIAW
Sprite Recorder
Button With Rollover Effect



Behavior Movable Hole with Mask Ink

Added on 7/8/1999


behavior D6_5 D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MatthewCaldwell

Immediately after your foreground pict in the cast, put a 1-bit picture castmember consisting of a huge black rectangle with a white circle the size of the hole you want in the middle of it. The rectangle needs to be large enough that its edges don"t start to clip the foreground pict when you move the hole all the way to the edge. Then, place foreground and background picts onstage, and set the foreground picts ink effect to "Mask". Then, place a large invisible tools palette rectangle over the two picts, and give it the following behavior

-- handler to move a hole around under mouse control
-- maskCast is the cast containing the bitmap mask for the hole
-- note that the stuff involving eensy is a workaround for the
-- problem with stage updates not getting flushed properly: by moving
-- our invisible rectangle slightly we persuade Director that the
-- stage really does need updating.

on mouseDown
  -- save our start position
  put the mouseH into oldH
  put the mouseV into oldV

  -- set up the stuff for the update workaround
  put -1 into eensy
  put the clickOn into thisSprite

  -- repeatedly move the mask in line with the cursor
  repeat while the mouseDown

    -- get the old regPoint
    put the regPoint of cast maskCast into blah
    put getAt(blah,1) into regH
    put getAt(blah,2) into regV

    -- get the new mouse position
    put the mouseV into newV
    put the mouseH into newH

    -- work out how much we"ve moved
    set hOffset = newH - oldH
    set vOffset = newV - oldV

    -- move the mask regPoint the same amount in the *opposite* direction
    set the regPoint of cast maskCast = point(regH-hOffset, regV-vOffset)

    -- shift the foreground sprite slightly to force an update
    set the locH of sprite thisSprite = the locH of sprite thisSprite + eensy

    -- make it shift *back* next time around
    set eensy = -eensy

    -- update

    -- save the new mouse position
    set oldH = newH
    set oldV = newV

  end repeat
   -- et voila!
end mouseDown



36 South Court Sq
Suite 300
Newnan, GA 30263

Send e-mail