A slightly more elegant method I've used is to prevent the behavior from
getting the event at all. This speeds up Director and precludes the
necessary of building "state machine" logic into your behaviors:
1) Create a parent script castmember (let's call it "eventKiller") with the
following code:
on enterFrame me
stopEvent
end enterFrame
on mouseEnter me
stopEvent
end mouseEnter
and so on for each event message that you wish to block your behavior from
responding to. You could even create an individual parent script for each
such event block (e.g. "mouseEnterKiller", "enterFrameKiller", etc.)
To activate your event blocker, simply use the following code:
(sprite nn).scriptInstanceList.addAt( 1, (script "eventKiller") )
where nn is the channel number of sprite to which you've attached the
behavior you wish to affect. It's very important that this event blocking
script be put *before* your behavior(s) already assigned to the sprite.
btw - you do NOT need to make an instance of (script "eventKiller") to use
it multiple times as there is nothing different being done or stored.
"stopEvent" is more powerful than the venerable "dontPassEvent" in that it
prevents Director from propagating events "sideways" through the
scriptInstanceList as well as "up" the event heirarchy.
To deactivate your event blocker, simply remove it from the scriptInstanceList:
(sprite nn).scriptInstanceList.deleteAt(1)
There are some obvious limitations in the usefulness of this approach but
it works quite well in many cases.
Regards,
Terry
At 9:00 PM -0800 1/4/02, Buzz Kettles wrote:
>I'd use the flag method and I'd use two state switching handlers so
>that I wouldn't have to think about phase issues.
>
>property objectState
>
>on beginSprite me
> activate -- if you want it to initialize to TRUE
>end
>
>on activate me
> objectState = TRUE
>end
>
>on deActivate me
> objectState = FALSE
>end
>
>on enterFrame me
> if objectState then
> -- code to execute of not goes here
> end if
>end
>
>then you can just use sendSprite to activate or deactivate it.
>sendSprite(theSpriteOfInterest, #activate)
> or
>sendSprite(theSpriteOfInterest, #deActivate)
--
...---===| Terry R. Schussler |===---...
...---===| Chief Investigator |===---...
on accessResources
coolSites = [ \
"http://macromediaSEMINARS.com/", "http://directorU.com", \
"http://multiuserU.com", "http://flash5U.com", \
"http://dreamweaverU.com", "http://behaviors.com/" ]
gotoNetPage coolSites[random(1, 6)]
end accessResources
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]