Package | impression.utilities |
Class | public class TypeUtils |
Inheritance | TypeUtils ![]() |
Method | Defined By | ||
---|---|---|---|
getBoolean(value:*):Boolean [static]
Returns the Boolean representation of value. | TypeUtils | ||
getNumber(value:*, defaultValue:Number):Number [static]
Returns the Number representation of value. | TypeUtils | ||
getString(value:*):String [static]
Returns the String representation of value. | TypeUtils | ||
sequentialArray(length:uint, start:Number = 0):Array [static]
Returns an ordered array of numbers, where each value in the array
is the array index plus start. | TypeUtils | ||
shuffleArray(items:Array, forceNewOrder:Boolean = false):void [static]
Randomizes the order of the items in the array. | TypeUtils |
getBoolean | () | method |
public static function getBoolean(value:*):Boolean
Returns the Boolean representation of value
.
Parameters
value:* — Expression identifying the item to return the Boolean representation of. value can be one of the following types:
|
Boolean — The Boolean representation of value .
|
getNumber | () | method |
public static function getNumber(value:*, defaultValue:Number):Number
Returns the Number representation of value
.
This method attempts to return the result of casting value
to a Number. If value
is null
, the casted result is NaN
, or an error occurs, the method returns
defaultValue
.
Parameters
value:* — Expression identifying the item to return the Number representation of.
| |
defaultValue:Number — The Number to return if a valid cast cannot be made.
|
Number — The Number representation of value , or defaultValue .
|
getString | () | method |
public static function getString(value:*):String
Returns the String representation of value
.
Parameters
value:* — Expression identifying the item to return the String representation of. value can be one of the following types:
|
String — The String representation of value .
|
sequentialArray | () | method |
public static function sequentialArray(length:uint, start:Number = 0):Array
Returns an ordered array of numbers, where each value in the array
is the array index plus start
.
Parameters
length:uint — The length of the returned array.
| |
start:Number (default = 0 ) — The value of the first element in the returned array.
|
Array — An Array of numbers, ordered from start to
start + [length - 1] .
|
shuffleArray | () | method |
public static function shuffleArray(items:Array, forceNewOrder:Boolean = false):void
Randomizes the order of the items in the array.
This method uses the Fisher-Yates algorithm to shuffle the items.
Parameters
items:Array — The array to shuffle.
| |
forceNewOrder:Boolean (default = false ) — Optional parameter indicating how randomization should occur.
If this value is true , the method makes a shallow copy of the array, shuffles
the original, and compares the shuffled result to the shallow copy. If the two arrays match,
the first item in the array is swapped with another item, ensuring that the array is not
in the original order.
|