Chapter 14
370
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 doesn’t 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 sprite’s
scriptInstanceList
property to an empty list([]). See
scriptInstanceList
in the Lingo Dictionary.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...