To round a value to the nearest multiple of x:
function roundTo(value:Number, to:Number):Number { return Math.round(value / to) * to; }
Example:
roundTo(8, 5); // 10 roundTo(17, 3); // 18