User Guide
270 Chapter 12: Methods
Parameters
intSpriteNum
Required. An integer that specifies the sprite whose horizontal coordinates are
evaluated against
intPosn.
intPosn Required. An integer to be evaluated against by the horizontal coordinates of the left and
right sides of the sprite identified by
intSpriteNum.
Example
These statements check the constrainH function for sprite 1 when it has left and right
coordinates of 40 and 60:
-- Lingo syntax
put(constrainH(1, 20)) -- 40
put(constrainH(1, 55)) -- 55
put(constrainH(1, 100)) -- 60
// JavaScript syntax
put(constrainH(1, 20)); // 40
put(constrainH(1, 55)); // 55
put(constrainH(1, 100)); // 60
This statement constrains a moveable slider (sprite 1) to the edges of a gauge (sprite 2) when the
mouse pointer goes past the edge of the gauge:
-- Lingo syntax
sprite(1).locH = _movie.constrainH(2, _mouse.mouseH)
// JavaScript syntax
sprite(1).locH = _movie.constrainH(2, _mouse.mouseH);
See also
constrainV(), Movie
constrainV()
Usage
-- Lingo syntax
_movie.constrainV(intSpriteNum, intPosn)
// JavaScript syntax
_movie.constrainV(intSpriteNum, intPosn);
Description
Movie method; returns an integer whose value depends on the vertical coordinates of the top and
bottom sides of a sprite.
The returned integer can be one of three possible values.
• If the intPosn parameter is between the values of the sprite’s top and bottom coordinates, the
returned integer equals
intPosn.
• If the intPosn parameter iis less than the value of the sprite’s top coordinate, the returned
integer changes to the value of the sprite’s top coordinate.
• If the intPosn parameter iis greater than the value of the sprite’s bottom coordinate, the
returned integer changes to the value of the sprite’s bottom coordinate.
This method does not change the sprite’s properties.