524
Chapter 12: Methods
For best results, send the message only to those sprites that will properly handle the message
through the
sendSprite()
method. No error will occur if the message is sent to all the sprites,
but performance may decrease. There may also be problems if different sprites have the
same handler in a behavior, so avoid conflicts by using unique names for messages that will
be broadcast.
After the message has been passed to all behaviors, the event follows the regular message
hierarchy: cast member script, frame script, then movie script.
When you use the
sendAllSprites()
method, be sure to do the following:
•
Replace
stringEventMessage
with the message.
•
Replace
args
with any arguments to be sent with the message.
If no sprite has an attached behavior containing the given handler,
sendAllSprites()
returns
FALSE
.
Parameters
stringEventMessage
Required. A string that specifies the message to send to all sprites.
args
Optional. An argument or arguments to send with the message.
Example
This handler sends the custom message
allSpritesShouldBumpCounter
and the argument
2
to
all sprites when the user clicks the mouse:
-- Lingo syntax
on mouseDown me
_movie.sendAllSprites(#allspritesShouldBumpCounter, 2)
end
// JavaScript syntax
function mouseDown() {
_movie.sendAllSprites("allspritesShouldBumpCounter", 2);
}
See also
Movie
,
sendSprite()
,
stopEvent()
sendEvent
Usage
member(
whichCastmember
).sendEvent(#
eventName, arg1, arg2,...
)
Description
3D command; sends an event and an arbitrary number of arguments to all scripts registered to
receive the event. Use
registerForEvent()
, or
setCollisionCallback()
to register scripts
for events.
Parameters
eventName
Required. Specifies the name of the event to send.
arg1, arg2, ...
Required. One or more arguments that are sent with the event
eventName
.
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...