This also works for AS3 but then you have to data type the precision:Number to precision:int in the function signature.

Sid

On Jan 27, 2009, at 11:20 AM, Sidney de Koning wrote:

function round(number:Number, precision:Number):Number
{
        var decimalPlaces:Number = Math.pow(10, precision);
        trace(Math.round(decimalPlaces * number) / decimalPlaces)
        return Math.round(decimalPlaces * number) / decimalPlaces;
}

round(2.5678, 2);

Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to