Math.clamp(number,lo,hi) +
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
Math.clamp(number, lo, hi)

Arguments
All are numbers or expressions.
number: Value to be clamped.
lo: Low clamp value.
hi: Hi clamp value.

Returns
Clamped value.

Description
If number <= lo returns lo; If number >= hi returns hi; otherwise returns number.

This is a convenient way of limiting values to a set boundary.

Sample
Math.clamp(-5
,2,15);    // returns 2
Math.clamp(4
.6,2,15);   // returns 4.6
Math.clamp(103
,2,15);   // returns 15

Flash MX Differences
This function is not implemented in Flash MX.