Packagecom.desuade.utils
Classpublic class Random
InheritanceRandom Inheritance Object
Subclasses RandomColor

Language Version : ActionScript 3
Since : 18.04.2009
Runtime Versions : AIR 1.0, Flash Player 9.0.0

The Random class offers an object or a static method to return a random Number between 2 specified values, also allowing for decimal place precision.



Public Properties
 PropertyDefined By
  max : Number
The Random object's maximum value for the random range.
Random
  min : Number
The Random object's minimum value for the random range.
Random
  precision : int
This is the amount of decimal places to keep when returning the value.
Random
Public Methods
 MethodDefined By
  
Random(min:Number, max:Number, precision:int = 0)
This creates a Random object than can be used over again for creating new random values from the same range.
Random
  
fromRange(min:Number, max:Number, precision:int = 0):*
[static] This static function is used to return a random value from a given range.
Random
  
toString():String
This returns a new random value within the range each time the Random object is read.
Random
  
valueOf():Number
This returns a new random value within the range each time the Random object is read.
Random
Property Detail
maxproperty
public var max:Number

The Random object's maximum value for the random range.

minproperty 
public var min:Number

The Random object's minimum value for the random range.

precisionproperty 
public var precision:int

This is the amount of decimal places to keep when returning the value. For example, values such as alpha use a 0-1 scale, so a precision of 2 would be used 0.00

Constructor Detail
Random()Constructor
public function Random(min:Number, max:Number, precision:int = 0)

This creates a Random object than can be used over again for creating new random values from the same range. Can be used with the Tween classes, as well as any other properties requiring a Number.

Parameters
min:Number — The first value in the range
 
max:Number — The second value in the range, up to but not including
 
precision:int (default = 0) — This determines how many decimal places the random value should be in

See also

Method Detail
fromRange()method
public static function fromRange(min:Number, max:Number, precision:int = 0):*

This static function is used to return a random value from a given range.

Parameters

min:Number — The first value in the range
 
max:Number — The second value in the range, up to but not including
 
precision:int (default = 0) — This determines how many decimal places the random value should be in

Returns
*

See also

toString()method 
public function toString():String

This returns a new random value within the range each time the Random object is read. Use var rns:String = String(my_random_object) to assign a constant string.

Returns
String
valueOf()method 
public function valueOf():Number

This returns a new random value within the range each time the Random object is read. Use var rn:Number = Number(my_random_object) to assign a constant number.

Returns
Number