
288
Chapter 12: Behaviors
Sending messages to specific behaviors only
The
call
method sends an event to specific behaviors. Unlike the
sendSprite
method, the
call
method does not 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
method.
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:
--Lingo syntax
on showScriptRefs me
put sprite(me.spriteNum).scriptInstanceList
end
// JavaScript syntax
function showScriptRefs() {
trace(sprite(spriteNum).scriptInstanceList);
}
This handler sends the message
bumpCounter
to the first script reference attached to sprite 1 (the
getAt
method identifies the first script reference in the
scriptInstanceList
):
--Lingo syntax
on mouseDown me
xref = getAt(sprite(1).scriptInstanceList, 1)
call (#bumpCounter, xref, 2)
end
// JavaScript syntax
function mouseDown() {
xref = sprite(1).scriptInstanceList.getAt(1);
bumpCounter (xref, 2);
}
Note:
The symbol (
#
) operator must precede the message in the
call
method.
To remove all instances of a sprite while the movie is playing:
•
Set the sprite’s
scriptInstanceList
property to an empty list([]). For more information
about this property, see the Scripting Reference topics in the Director Help Panel.
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...