1006
Chapter 14: Properties
spriteNum
Usage
-- Lingo syntax
spriteObjRef
.spriteNum
// JavaScript syntax
spriteObjRef
.spriteNum;
Description
Sprite property; determines the channel number the behavior’s sprite is in and makes it available
to any behaviors. Read-only.
Simply declare the property at the top of the behavior, along with any other properties the
behavior may use.
If you use a
new()
handler to create an instance of the behavior, the script’s
new()
handler must
explicitly set the
spriteNum
property to the sprite’s number. This provides a way to identify the
sprite the script is attached to. The sprite’s number must be passed to the
new()
handler as an
argument when the
new()
handler is called.
Example
In this handler, the
spriteNum
property is automatically set for script instances that are created by
the system:
-- Lingo syntax
property spriteNum, pMySpriteRef
on mouseDown me
sprite(spriteNum).member = member("DownPict")
end
// JavaScript syntax
function mouseDown() {
sprite(this.spriteNum).member = member("DownPict");
}
This handler uses the automatic value inserted into the
spriteNum
property to assign the sprite
reference to a new property variable
pMySpriteRef
, as a convenience:
-- Lingo syntax
property spriteNum, pMySpriteRef
on beginSprite me
pMySpriteRef = sprite(me.spriteNum)
end
// JavaScript syntax
function beginSprite() {
this.pMySpriteRef = sprite(this.spriteNum);
}
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...