
56
Chapter 3: Sprites
To view a sprite in the Score by its name:
1
In the Score, select the Sprite labels pop-up menu.
2
Select Name. All the sprites in the score appear with their sprite name listed.
To view a sprite on the Stage by its name:
•
Select a sprite on the Stage. The sprite name appears on the second line of the sprite overlay.
To edit the name of a sprite:
1
Select the sprite and open the Property inspector.
2
Enter a name in the Name text box.
Setting the Sprite name property in Lingo or JavaScript syntax
The new sprite name property is accessible as a standard sprite property. The
name
property can
be read at all times, but names can only be assigned via script when in score recording mode.
The syntax is as follows:
put sprite(1).name -- this displays the name in the message window.
You can also refer to the sprite by using its given name when evoking script commands on the
sprite. For example:
sendSprite ("pete", #handlername) -- call the "handlername" method in
sprite("pete")
put sprite("somename").rect -- display the sprite's rect
To find out what sprite is targeted for a particular name, you can use the following expression:
sprite("myName").spriteNum
To create a name for a sprite, the assignment must be made in score recording mode. Note that
you don’t have to use the updateFrame command, but the record frame must be a frame where
the sprite exists in the score.
beginrecording
sprite(2).name = "tubular"
endrecording
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...