/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * takes a number and gives it to bounderies: @n --> the number @nMin --> minimal value fo the @n number @nMax --> the maximal value example: NumberTools.boundrary(10,5,15) returns 10, NumberTools.boundrary(4,5,15) returns 5(min). NumberTools.boundrary(20,5,15) returns 15 **/ public static function boundrary(n:Number, nMin:Number=0, nMax:Number=1):Number{ return Math.max(Math.min(n, nMax),nMin); } /** *The function centers values **/ public static function center( container:Number, content:Number):int { return Math.round((container - content)/2); }