Clipping values between 0 and 1
Sometimes its handy to normalize of clamp values between a specific range. You can do this very easily with Math.min() and Math.max().
Here is a code snippet to show you how:
Clipping values to stay between 0 and 1
- // clipping values for volume
- function set volume( value:Number ):void {
- _soundTransform.volume = Math.min(Math.max(value, 0), 1);
- }






Great information! I’ve been looking for something like this for a while now. Thanks!