User Guide
sendSprite() 525
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. 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()
Usage
-- Lingo syntax
_movie.sendSprite(spriteNameOrNum, event {, args})
// JavaScript syntax
_movie.sendSprite(spriteNameOrNum, event {, args});
Description
Movie method; 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.
Parameters
spriteNameOrNum
Required. A string or an integer that specifies the name or number of the
sprite that will receive the event.
event Required. A symbol or string that specifies the event to send to the specified sprite.
args Optional. An argument or arguments to send with the message.
Example
This handler sends the custom message bumpCounter and the argument 2 to sprite 1 when the
user clicks:
-- Lingo syntax
on mouseDown me
_movie.sendSprite(1, #bumpCounter, 2)
end
// JavaScript syntax
function mouseDown() {
_movie.sendSprite(1, "bumpCounter", 2);
}