User Guide

586
Example
This handler sends the custom message allSpritesShouldBumpCounter and the argument 2 to all
sprites when the user clicks the mouse:
on mouseDown me
sendAllSprites (#allSpritesShouldBumpCounter, 2)
end
See also
sendSprite
sendEvent
Syntax
member(whichCastmember).sendEvent(#eventName, arg1, arg2,...)
Description
3D command; sends the event eventName, and an arbitrary number of arguments (arg1, arg2,
...
), to all scripts registered to receive the event. Use registerForEvent(), or
setCollisionCallback() to register scripts for events.
Example
The first line in this example creates an instance of a parent script named "tester". The second
line sets the handler of the script instance, jumpPluto, as the handler to be called when the
#jump
event is sent. The third line registers a movie script handler named jumpMars as another handler
to be called when the
#jump event is sent. The fourth line sends the #jump event. The handlers
#jumpMars in a movie script and #jumpPluto are called, along with any other handlers registered for
the
#jump event. Note that a script instance value of 0 indicates that you are registering a handler
of a movie script, as opposed to a handler of a behavior instance or of a child of a parent script.
t = new (script "tester")
member("scene").registerForEvent(#jump, #jumpPluto, t)
member("scene").registerForEvent(#jump, #jumpMars, 0)
member("scene").sendEvent(#jump)
See also
registerScript(), registerForEvent(), setCollisionCallback()
sendSprite
Syntax
sendSprite (whichSprite, #customMessage, args)
Description
Command; sends a message to all scripts attached to a specified sprite.
Messages sent using
sendSprite are sent to each of the scripts attached to the sprite. The messages
then follow the regular message hierarchy: cast member script, frame script, and movie script.
If the given sprite does not have an attached behavior containing the given handler,
sendSprite
returns
FALSE.