Get Random Number From A Range

December 23rd, 2011 by aabhaanjan

images
[xml]
package
{
import flash.display.MovieClip;

/**
* …
* @Description : This class can be used when we need a Random number from a specific range.
* For example if we need a Random number between 10-20. We can use this class.
* @author Aava
*/
public class GetRandomNumberFromARange extends MovieClip
{

public function GetRandomNumberFromARange()
{
super();
}

/*
* @Description : Pass the maximum value and minimum value as paramere.
* @Return : It will return the random value from the given range.
* @Parameters : __MAX represents Maximum value of range.
* @Parameters : __MIN represents Minimum value of range.
*/
public function getRandomNumber(__MAX:Number, __MIN:Number):Number {
var __range:Number = __MAX – __MIN
var __someNum:Number = int(Math.random() * __range) + __MIN
return __someNum;
}
}

}
[/xml]