User Guide

838 Chapter 14: Properties
Sprite coordinates are relative to the upper left corner of the Stage.
To make the value last beyond the current sprite, make the sprite a scripted sprite.
Example
This statement puts sprite 15 at the same vertical location as the mouse click:
-- Lingo syntax
sprite(15).locV = _mouse.mouseV
// JavaScript syntax
sprite(15).locV = _mouse.mouseV;
See also
bottom, height, left, locH, point(), right, Sprite, top, updateStage()
locZ
Usage
-- Lingo syntax
spriteObjRef.locZ
// JavaScript syntax
spriteObjRef.locZ;
Description
Sprite property; specifies the dynamic Z-order of a sprite, to control layering without having to
manipulate sprite channels and properties. Read/write.
This property can have an integer value from negative 2 billion to positive 2 billion. Larger
numbers cause the sprite to appear in front of sprites with smaller numbers. If two sprites have the
same
locZ value, the channel number then takes precedence for deciding the final display order
of those two sprites. This means sprites in lower numbered channels appear behind sprites in
higher numbered channels even when the
locZ values are equal.
By default, each sprite has a
locZ value equal to its own channel number.
Layer-dependent operations such as hit detection and mouse events obey sprites
locZ values, so
changing a sprites
locZ value can make the sprite partially or completely obscured by other
sprites and the user may be unable to click on the sprite.
Other Director functions do not follow the
locZ ordering of sprites. Generated events still begin
with channel 1 and increase consecutively from there, regardless of the sprites Z-order.
Example
This handler uses a global variable called gHighestSprite which has been initialized in the
startMovie handler to the number of sprites used. When the sprite is clicked, its locZ is set to
gHighestSprite + 1, which moves the sprite to the foreground on the stage. Then gHighestSprite
is incremented by 1 to prepare for the next mouseUp call.
-- Lingo syntax
on mouseUp me
global gHighestSprite
sprite(me.spriteNum).locZ = gHighestSprite + 1
gHighestSprite = gHighestSprite + 1
end