User Guide

Chapter 14370
For example, this handler sends the custom message bumpCounter and the argument 2 to sprite 1
when the user clicks the mouse:
on mouseDown me
sendSprite (1, #bumpCounter, 2)
end
Note: The symbol (#) operator must precede the message in the sendSprite command.
Sending messages to all sprites
The
sendAllSprites command sends a message to every sprite in the frame. If no behavior of
the specified sprite has a handler that corresponds to the message, the message passes to the cast
member script, the frame script, and then the movie script. See
sendAllSprites in the
Lingo Dictionary.
For example, this handler sends the custom message
bumpCounter and the argument 2 to all
sprites in the frame when the user clicks the mouse button:
on mouseDown me
sendAllSprites (#bumpCounter, 2)
end
Note: The symbol (#) operator must precede the message in the sendAllSprites command.
Sending messages to specific behaviors only
The call command sends an event to specific behaviors. Unlike the sendSprite command,
the
call command doesnt pass the message to frame scripts, scripts of the cast member, or
movie scripts.
Before sending a message to a specific behavior, check the
scriptInstanceList sprite property
to find a behavior script reference to use with the
call command.
The
scriptInstanceList property provides a list of references for the behaviors attached to a
sprite while a movie is playing.
For example, this handler displays the list of references for all behaviors attached to the same
sprite as this behavior’s handler:
on showScriptRefs me
put the scriptInstanceList of sprite the ¬
spriteNum of me
end
This handler sends the message bumpCounter to the first script reference attached to sprite 1 (the
getAt function identifies the first script reference in the scriptInstanceList):
on mouseDown me
xref = getAt (the scriptInstanceList of sprite 1,1)
call (#bumpCounter, xref, 2)
end
Note: The symbol (#) operator must precede the message in the call command.
To remove instances of a sprite while the movie is playing:
Set the sprites scriptInstanceList property to an empty list([]). See scriptInstanceList
in the Lingo Dictionary.