Restricting a number to a certain range
Quite often I need to restrict a number to a range with a defined maximum and minimum value. Rather than using if else statements you can do this simply with Math.max and Math.min: var restricted_value:Number = Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));


LinkedIn
Twitter
![Validate my RSS feed [Valid RSS]](http://blog.sitedaniel.com/valid-rss.png)