View Single Post
Codemonkey's Avatar Codemonkey Codemonkey is offline Super Moderator 2006-11-05 #14 Old  
012 - Clipping a number
Last edited by Codemonkey : 2006-11-05 at 08:35.
 
If you want to make sure a number is within a certain range or clip it otherwise, here's a simple way to do this:

ActionScript Code:
  1. function clip(value:Number, min:Number, max:Number):Number {
  2.         return Math.min(Math.max(value, min), max);
  3.     }