Sending messages to behaviors attached to sprites
Script can run handlers in behaviors attached to specific sprites by sending messages to the
behaviors attached to one sprite, all sprites, or several specific sprites.
Sending messages to a sprite
The
sendSprite
a handler that corresponds to the message, the message passes to the cast member script, the frame
script, and then the movie script. For more information about this method, see the Scripting
Reference topics in the Director Help Panel.
For example, this handler sends the custom message
when the user clicks the mouse:
--Lingo syntax
on mouseDown me
sendSprite (1, #bumpCounter, 2)
end
// JavaScript syntax
function mouseDown() {
_movie.sendSprite(1, symbol("bumpCounter"), 2);
}
Note: The symbol (
Sending messages to all sprites
The
sendAllSprites
handler that corresponds to the message, the message passes to the cast member script, the frame
script, and then the movie script. For more information about this method, see the Scripting
Reference topics in the Director Help Panel.
For example, this handler sends the custom message
sprites in the frame when the user clicks the mouse button:
--Lingo syntax
on mouseDown me
sendAllSprites (#bumpCounter, 2)
end
// JavaScript syntax
function mouseDown() {
_movie.sendAllSprites(symbol("bumpCounter"), 2);
}
Note: The symbol (
method sends a message to a specified sprite. If none of the sprite's behaviors has
) operator must precede the message in the
#
method sends a message to every sprite in the frame. If no behavior has a
) operator must precede the message in the
#
bumpCounter
sendSprite
bumpCounter
sendAllSprites
Sending messages to behaviors attached to sprites
and the argument 2 to sprite 1
method.
and the argument 2 to all
method.
287
Need help?
Do you have a question about the DIRECTOR MX 2004-USING DIRECTOR and is the answer not in the manual?
Questions and answers