
Sending messages to behaviors attached to sprites
287
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
method sends a message to a specified sprite. If none of the sprite’s behaviors has
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
bumpCounter
and the argument 2 to sprite 1
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 (
#
) operator must precede the message in the
sendSprite
method.
Sending messages to all sprites
The
sendAllSprites
method sends a message to every sprite in the frame. If no behavior has 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
bumpCounter
and the argument 2 to all
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 (
#
) operator must precede the message in the
sendAllSprites
method.
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...