Lingo Dictionary > A-C > constrainH() |
![]() ![]() ![]() |
constrainH()
Syntax
constrainH (
whichSprite
,
integerExpression
)
Description
Function; evaluates integerExpression
and then returns a value that depends on the horizontal coordinates of the left and right edges of whichSprite,
as follows:
![]() |
When the value is between the left and right coordinates, the value doesn't change. |
![]() |
When the value is less than the left horizontal coordinate, the value changes to the value of the left coordinate. |
![]() |
When the value is greater than the right horizontal coordinate, the value changes to the value of the right coordinate. |
The constrainH
and constrainV
functions constrain only one axis each; the constraint
sprite property limits both. Note that this function does not change the sprite's properties.
Example
These statements check the constrainH
function for sprite 1 when it has left and right coordinates of 40 and 60:
put constrainH(1, 20) -- 40 put constrainH(1, 55) -- 55 put constrainH(1, 100) -- 60
Example
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:
set the locH of sprite 1 to constrainH(2, the mouseH)
See also
constrainV()
, constraint
, left
, right
![]() ![]() ![]() |