Packageorg.flixel
Classpublic class FlxU
InheritanceFlxU Inheritance Object



Public Methods
 MethodDefined By
  
abs(Value:Number):Number
[static] Calculate the absolute value of a number.
FlxU
  
bound(Value:Number, Min:Number, Max:Number):Number
[static] Bound a number by a minimum and maximum.
FlxU
  
ceil(Value:Number):Number
[static] Round up to the next whole number.
FlxU
  
compareClassNames(Object1:Object, Object2:Object):Boolean
[static] Check to see if two objects have the same class name.
FlxU
  
computeVelocity(Velocity:Number, Acceleration:Number = 0, Drag:Number = 0, Max:Number = 10000):Number
[static] A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
FlxU
  
floor(Value:Number):Number
[static] Round down to the next whole number.
FlxU
  
formatArray(AnyArray:Array):String
[static] Generate a comma-separated string from an array.
FlxU
  
formatMoney(Amount:Number, ShowDecimal:Boolean = true, EnglishStyle:Boolean = true):String
[static] Automatically commas and decimals in the right places for displaying money amounts.
FlxU
  
formatTicks(StartTicks:uint, EndTicks:uint):String
[static] Takes two "ticks" timestamps and formats them into the number of seconds that passed as a String.
FlxU
  
formatTime(Seconds:Number, ShowMS:Boolean = false):String
[static] Format seconds as minutes with a colon, an optionally with milliseconds too.
FlxU
  
getAngle(Point1:FlxPoint, Point2:FlxPoint):Number
[static] Calculates the angle between two points.
FlxU
  
getClass(Name:String):Class
[static] Look up a Class object by its string name.
FlxU
  
getClassName(Obj:Object, Simple:Boolean = false):String
[static] Get the String name of any Object.
FlxU
  
getDistance(Point1:FlxPoint, Point2:FlxPoint):Number
[static] Calculate the distance between two points.
FlxU
  
getHSB(Color:uint, Results:Array = null):Array
[static] Loads an array with the HSB values of a Flash uint color.
FlxU
  
getRandom(Objects:Array, StartIndex:uint = 0, Length:uint = 0):Object
[static] Fetch a random entry from the given array.
FlxU
  
getRGBA(Color:uint, Results:Array = null):Array
[static] Loads an array with the RGBA values of a Flash uint color.
FlxU
  
getTicks():uint
[static] Just grabs the current "ticks" or time in milliseconds that has passed since Flash Player started up.
FlxU
  
makeColor(Red:uint, Green:uint, Blue:uint, Alpha:Number = 1.0):uint
[static] Generate a Flash uint color from RGBA components.
FlxU
  
makeColorFromHSB(Hue:Number, Saturation:Number, Brightness:Number, Alpha:Number = 1.0):uint
[static] Generate a Flash uint color from HSB components.
FlxU
  
max(Number1:Number, Number2:Number):Number
[static] Figure out which number is larger.
FlxU
  
min(Number1:Number, Number2:Number):Number
[static] Figure out which number is smaller.
FlxU
  
openURL(URL:String):void
[static] Opens a web page in a new tab or window.
FlxU
  
rotatePoint(X:Number, Y:Number, PivotX:Number, PivotY:Number, Angle:Number, Point:FlxPoint = null):FlxPoint
[static] Rotates a point in 2D space around another point by the given angle.
FlxU
  
round(Value:Number):Number
[static] Round to the closest whole number.
FlxU
  
shuffle(Objects:Array, HowManyTimes:uint):Array
[static] Shuffles the entries in an array into a new random order.
FlxU
  
srand(Seed:Number):Number
[static] Generates a random number based on the seed provided.
FlxU
Method Detail
abs()method
public static function abs(Value:Number):Number

Calculate the absolute value of a number.

Parameters

Value:Number — Any number.

Returns
Number — The absolute value of that number.
bound()method 
public static function bound(Value:Number, Min:Number, Max:Number):Number

Bound a number by a minimum and maximum. Ensures that this number is no smaller than the minimum, and no larger than the maximum.

Parameters

Value:Number — Any number.
 
Min:Number — Any number.
 
Max:Number — Any number.

Returns
Number — The bounded value of the number.
ceil()method 
public static function ceil(Value:Number):Number

Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.

Parameters

Value:Number — Any number.

Returns
Number — The rounded value of that number.
compareClassNames()method 
public static function compareClassNames(Object1:Object, Object2:Object):Boolean

Check to see if two objects have the same class name.

Parameters

Object1:Object — The first object you want to check.
 
Object2:Object — The second object you want to check.

Returns
Boolean — Whether they have the same class name or not.
computeVelocity()method 
public static function computeVelocity(Velocity:Number, Acceleration:Number = 0, Drag:Number = 0, Max:Number = 10000):Number

A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.

Parameters

Velocity:Number — Any component of velocity (e.g. 20).
 
Acceleration:Number (default = 0) — Rate at which the velocity is changing.
 
Drag:Number (default = 0) — Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
 
Max:Number (default = 10000) — An absolute value cap for the velocity.

Returns
Number — The altered Velocity value.
floor()method 
public static function floor(Value:Number):Number

Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.

Parameters

Value:Number — Any number.

Returns
Number — The rounded value of that number.
formatArray()method 
public static function formatArray(AnyArray:Array):String

Generate a comma-separated string from an array. Especially useful for tracing or other debug output.

Parameters

AnyArray:Array — Any Array object.

Returns
String — A comma-separated String containing the .toString() output of each element in the array.
formatMoney()method 
public static function formatMoney(Amount:Number, ShowDecimal:Boolean = true, EnglishStyle:Boolean = true):String

Automatically commas and decimals in the right places for displaying money amounts. Does not include a dollar sign or anything, so doesn't really do much if you call say var results:String = FlxU.formatMoney(10,false); However, very handy for displaying large sums or decimal money values.

Parameters

Amount:Number — How much moneys (in dollars, or the equivalent "main" currency - i.e. not cents).
 
ShowDecimal:Boolean (default = true) — Whether to show the decimals/cents component. Default value is true.
 
EnglishStyle:Boolean (default = true) — Major quantities (thousands, millions, etc) separated by commas, and decimal by a period. Default value is true.

Returns
String — A nicely formatted String. Does not include a dollar sign or anything!
formatTicks()method 
public static function formatTicks(StartTicks:uint, EndTicks:uint):String

Takes two "ticks" timestamps and formats them into the number of seconds that passed as a String. Useful for logging, debugging, the watch window, or whatever else.

Parameters

StartTicks:uint — The first timestamp from the system.
 
EndTicks:uint — The second timestamp from the system.

Returns
String — A String containing the formatted time elapsed information.
formatTime()method 
public static function formatTime(Seconds:Number, ShowMS:Boolean = false):String

Format seconds as minutes with a colon, an optionally with milliseconds too.

Parameters

Seconds:Number — The number of seconds (for example, time remaining, time spent, etc).
 
ShowMS:Boolean (default = false) — Whether to show milliseconds after a "." as well. Default value is false.

Returns
String — A nicely formatted String, like "1:03".
getAngle()method 
public static function getAngle(Point1:FlxPoint, Point2:FlxPoint):Number

Calculates the angle between two points. 0 degrees points straight up.

Parameters

Point1:FlxPoint — The X coordinate of the point.
 
Point2:FlxPoint — The Y coordinate of the point.

Returns
Number — The angle in degrees, between -180 and 180.
getClass()method 
public static function getClass(Name:String):Class

Look up a Class object by its string name.

Parameters

Name:String — The String name of the Class you are interested in.

Returns
Class — A Class object.
getClassName()method 
public static function getClassName(Obj:Object, Simple:Boolean = false):String

Get the String name of any Object.

Parameters

Obj:Object — The Object object in question.
 
Simple:Boolean (default = false) — Returns only the class name, not the package or packages.

Returns
String — The name of the Class as a String object.
getDistance()method 
public static function getDistance(Point1:FlxPoint, Point2:FlxPoint):Number

Calculate the distance between two points.

Parameters

Point1:FlxPoint — A FlxPoint object referring to the first location.
 
Point2:FlxPoint — A FlxPoint object referring to the second location.

Returns
Number — The distance between the two points as a floating point Number object.
getHSB()method 
public static function getHSB(Color:uint, Results:Array = null):Array

Loads an array with the HSB values of a Flash uint color. Hue is a value between 0 and 360. Saturation, Brightness and Alpha are as floating point numbers between 0 and 1.

Parameters

Color:uint — The color you want to break into components.
 
Results:Array (default = null) — An optional parameter, allows you to use an array that already exists in memory to store the result.

Returns
Array — An Array object containing the Red, Green, Blue and Alpha values of the given color.
getRandom()method 
public static function getRandom(Objects:Array, StartIndex:uint = 0, Length:uint = 0):Object

Fetch a random entry from the given array. Will return null if random selection is missing, or array has no entries. FlxG.getRandom() is deterministic and safe for use with replays/recordings. HOWEVER, FlxU.getRandom() is NOT deterministic and unsafe for use with replays/recordings.

Parameters

Objects:Array — A Flash array of objects.
 
StartIndex:uint (default = 0) — Optional offset off the front of the array. Default value is 0, or the beginning of the array.
 
Length:uint (default = 0) — Optional restriction on the number of values you want to randomly select from.

Returns
Object — The random object that was selected.
getRGBA()method 
public static function getRGBA(Color:uint, Results:Array = null):Array

Loads an array with the RGBA values of a Flash uint color. RGB values are stored 0-255. Alpha is stored as a floating point number between 0 and 1.

Parameters

Color:uint — The color you want to break into components.
 
Results:Array (default = null) — An optional parameter, allows you to use an array that already exists in memory to store the result.

Returns
Array — An Array object containing the Red, Green, Blue and Alpha values of the given color.
getTicks()method 
public static function getTicks():uint

Just grabs the current "ticks" or time in milliseconds that has passed since Flash Player started up. Useful for finding out how long it takes to execute specific blocks of code.

Returns
uint — A uint to be passed to FlxU.endProfile().
makeColor()method 
public static function makeColor(Red:uint, Green:uint, Blue:uint, Alpha:Number = 1.0):uint

Generate a Flash uint color from RGBA components.

Parameters

Red:uint — The red component, between 0 and 255.
 
Green:uint — The green component, between 0 and 255.
 
Blue:uint — The blue component, between 0 and 255.
 
Alpha:Number (default = 1.0) — How opaque the color should be, either between 0 and 1 or 0 and 255.

Returns
uint — The color as a uint.
makeColorFromHSB()method 
public static function makeColorFromHSB(Hue:Number, Saturation:Number, Brightness:Number, Alpha:Number = 1.0):uint

Generate a Flash uint color from HSB components.

Parameters

Hue:Number — A number between 0 and 360, indicating position on a color strip or wheel.
 
Saturation:Number — A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant.
 
Brightness:Number — A number between 0 and 1, indicating how bright the color should be. 0 is black, 1 is full bright.
 
Alpha:Number (default = 1.0) — How opaque the color should be, either between 0 and 1 or 0 and 255.

Returns
uint — The color as a uint.
max()method 
public static function max(Number1:Number, Number2:Number):Number

Figure out which number is larger.

Parameters

Number1:Number — Any number.
 
Number2:Number — Any number.

Returns
Number — The larger of the two numbers.
min()method 
public static function min(Number1:Number, Number2:Number):Number

Figure out which number is smaller.

Parameters

Number1:Number — Any number.
 
Number2:Number — Any number.

Returns
Number — The smaller of the two numbers.
openURL()method 
public static function openURL(URL:String):void

Opens a web page in a new tab or window. MUST be called from the UI thread or else badness.

Parameters

URL:String — The address of the web page.

rotatePoint()method 
public static function rotatePoint(X:Number, Y:Number, PivotX:Number, PivotY:Number, Angle:Number, Point:FlxPoint = null):FlxPoint

Rotates a point in 2D space around another point by the given angle.

Parameters

X:Number — The X coordinate of the point you want to rotate.
 
Y:Number — The Y coordinate of the point you want to rotate.
 
PivotX:Number — The X coordinate of the point you want to rotate around.
 
PivotY:Number — The Y coordinate of the point you want to rotate around.
 
Angle:Number — Rotate the point by this many degrees.
 
Point:FlxPoint (default = null) — Optional FlxPoint to store the results in.

Returns
FlxPoint — A FlxPoint containing the coordinates of the rotated point.
round()method 
public static function round(Value:Number):Number

Round to the closest whole number. E.g. round(1.7) == 2, and round(-2.3) == -2.

Parameters

Value:Number — Any number.

Returns
Number — The rounded value of that number.
shuffle()method 
public static function shuffle(Objects:Array, HowManyTimes:uint):Array

Shuffles the entries in an array into a new random order. FlxG.shuffle() is deterministic and safe for use with replays/recordings. HOWEVER, FlxU.shuffle() is NOT deterministic and unsafe for use with replays/recordings.

Parameters

Objects:Array — A Flash Array object containing...stuff.
 
HowManyTimes:uint — How many swaps to perform during the shuffle operation. Good rule of thumb is 2-4 times as many objects are in the list.

Returns
Array — The same Flash Array object that you passed in in the first place.
srand()method 
public static function srand(Seed:Number):Number

Generates a random number based on the seed provided.

Parameters

Seed:Number — A number between 0 and 1, used to generate a predictable random number (very optional).

Returns
Number — A Number between 0 and 1.