ActionScript 3 Random Value Generation Random number between min and max values


Example

function randomMinMax(min:Number, max:Number):Number {
    return (min + (Math.random() * Math.abs(max - min)));
}

This function is called by passing a range of minimum and maximum values.

Example:

randomMinMax(1, 10);

Example outputs:

  • 1.661770915146917
  • 2.5521070677787066
  • 9.436270965728909