Lingo Dictionary > S > spriteNum |
![]() ![]() ![]() |
spriteNum
Syntax
spriteNum
the spriteNum of me
Description
Sprite property; determines the channel number the behavior's sprite is in and makes it available to any behaviors. Simply declare the property at the top of the behavior, along with any other properties the behavior may use.
If you use an on new
handler to create an instance of the behavior, the script's on 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 on new
handler as an argument when the on new
handler is called.
Example
In this handler, the spriteNum
property is automatically set for script instances that are created by the system:
property spriteNum on mouseDown me sprite(spriteNum).member = member("DownPict") end
Example
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:
property spriteNum, pMySpriteRef on beginSprite me pMySpriteRef = sprite(me.spriteNum) end
This approach allows the use of the reference pMySpriteRef
later in the script, with the handler using the syntax
currMember = pMySpriteRef.member
instead of the following syntax which is somewhat longer:
currMember = sprite(spriteNum).member
This alternative approach is merely for convenience, and provides no different functionality.
See also
on beginSprite
, on endSprite
, currentSpriteNum
![]() ![]() ![]() |