A class primarily containing functions related to formatting different data types to strings.

Static methods

@:value({ Invert : false })staticarrayToCSV(Data:Array<Int>, Width:Int, Invert:Bool = false):String

Converts a one-dimensional array of tile data to a comma-separated string.

Parameters:

Data

An array full of integer tile references.

Width

The number of tiles in each row.

Invert

Recommended only for 1-bit arrays - changes 0s to 1s and vice versa.

Returns:

A comma-separated string containing the level data in a FlxTilemap-friendly format.

@:value({ Scale : 1, Invert : false })staticbitmapToCSV(Bitmap:BitmapData, Invert:Bool = false, Scale:Int = 1, ?ColorMap:Array<FlxColor>):String

Converts a BitmapData object to a comma-separated string. Black pixels are flagged as 'solid' by default, non-black pixels are set as non-colliding. Black pixels must be PURE BLACK.

Parameters:

Bitmap

A Flash BitmapData object, preferably black and white.

Invert

Load white pixels as solid instead.

Scale

Default is 1. Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.

ColorMap

An array of color values (alpha values are ignored) in the order they're intended to be assigned as indices

Returns:

A comma-separated string containing the level data in a FlxTilemap-friendly format.

staticinlinecontains(s:String, str:String):Bool

staticfilterDigits(Input:String):String

Takes a string and filters out everything but the digits.

Parameters:

Input

The input string

Returns:

The output string, digits-only

staticformatArray(AnyArray:Array<Dynamic>):String

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

Parameters:

AnyArray

Any Array object.

Returns:

A comma-separated String containing the .toString() output of each element in the array.

@:value({ Precision : 2 })staticformatBytes(Bytes:Float, Precision:Int = 2):String

Takes an amount of bytes and finds the fitting unit. Makes sure that the value is below 1024. Example: formatBytes(123456789); -> 117.74MB

@:value({ EnglishStyle : true, ShowDecimal : true })staticformatMoney(Amount:Float, ShowDecimal:Bool = true, EnglishStyle:Bool = 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 FlxString.formatMoney(10, false). However, very handy for displaying large sums or decimal money values.

Parameters:

Amount

How much moneys (in dollars, or the equivalent "main" currency - i.e. not cents).

ShowDecimal

Whether to show the decimals/cents component.

EnglishStyle

Major quantities (thousands, millions, etc) separated by commas, and decimal by a period.

Returns:

A nicely formatted String. Does not include a dollar sign or anything!

@:has_untypedstaticformatStringMap(AnyMap:Map<String, Dynamic>):String

Generate a comma-separated string representation of the keys of a StringMap.

Parameters:

AnyMap

A StringMap object.

Returns:

A String formatted like this: key1, key2, ..., keyX

staticinlineformatTicks(StartTicks:Int, EndTicks:Int):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

The first timestamp from the system.

EndTicks

The second timestamp from the system.

Returns:

A String containing the formatted time elapsed information.

@:value({ ShowMS : false })staticformatTime(Seconds:Float, ShowMS:Bool = false):String

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

Parameters:

Seconds

The number of seconds (for example, time remaining, time spent, etc).

ShowMS

Whether to show milliseconds after a "." as well. Default value is false.

Returns:

A nicely formatted String, like "1:03".

@:value({ simple : false })staticgetClassName(objectOrClass:Dynamic, simple:Bool = false):String

Get the string name of any class or class instance. Wraps Type.getClassName().

Parameters:

objectOrClass

The class or class instance in question.

simple

Returns only the type name, without package(s).

Returns:

The name of the class as a string.

staticgetDebugString(LabelValuePairs:Array<LabelValuePair>):String

Helper function to create a string for toString() functions. Automatically rounds values according to FlxG.debugger.precision. Strings are formatted in the format: (x: 50 | y: 60 | visible: false)

Parameters:

LabelValuePairs

Array with the data for the string

staticgetDomain(url:String):String

Returns the domain from the specified URL. The domain, in this case, refers specifically to the first and second levels only. For example, the domain for "api.haxe.org" is "haxe.org".

Returns:

The domain from the URL; or the empty string ("") upon failure.

@:value({ simple : false })staticgetEnumName(enumValueOrEnum:OneOfTwo<EnumValue, Enum<Dynamic>>, simple:Bool = false):String

Get the string name of any enum or enum value. Wraps Type.getEnumName().

Parameters:

enumValueOrEnum

The enum value or enum in question.

simple

Returns only the type name, without package(s).

Returns:

The name of the enum as a string.

Available since

4.4.0

.

staticgetHost(url:String):String

Returns the host from the specified URL. The host is one of three parts that comprise the authority. (User and port are the other two parts.) For example, the host for "ftp://anonymous@ftp.domain.test:990/" is "ftp.domain.test".

Returns:

The host from the URL; or the empty string ("") upon failure.

Available since

4.3.0

.

@:value({ Underlined : false, Italic : false, Bold : false, Color : "FFFFFF", Size : 12 })statichtmlFormat(Text:String, Size:Int = 12, Color:String = "FFFFFF", Bold:Bool = false, Italic:Bool = false, Underlined:Bool = false):String

Format a text with html tags - useful for TextField.htmlText. Used by the log window of the debugger.

Parameters:

Text

The text to format

Size

The text size, using the font-size-tag

Color

The text color, using font-color-tag

Bold

Whether the text should be bold (b-tag)

Italic

Whether the text should be italic (i-tag)

Underlined

Whether the text should be underlined (u-tag)

Returns:

The html-formatted text.

@:value({ Scale : 1, Invert : false })staticimageToCSV(ImageFile:Dynamic, Invert:Bool = false, Scale:Int = 1, ?ColorMap:Array<FlxColor>):String

Converts a resource image file to a comma-separated string. Black pixels are flagged as 'solid' by default, non-black pixels are set as non-colliding. Black pixels must be PURE BLACK.

Parameters:

ImageFile

An embedded graphic, preferably black and white.

Invert

Load white pixels as solid instead.

Scale

Default is 1. Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.

ColorMap

An array of color values (alpha values are ignored) in the order they're intended to be assigned as indices

Returns:

A comma-separated string containing the level data in a FlxTilemap-friendly format.

staticinlineinsert(s:String, pos:Int, insertion:String):String

Inserts insertion into s at index pos.

staticinlineisNullOrEmpty(s:String):Bool

Returns true if s equals null or is empty.

Available since

4.1.0

.

staticinlineremove(s:String, sub:String):String

Removes occurrences of a substring by calling StringTools.replace(s, sub, "").

@:value({ Simple : true })staticinlinesameClassName(Obj1:Dynamic, Obj2:Dynamic, Simple:Bool = true):Bool

Helper function that uses getClassName to compare two objects' class names.

Parameters:

Obj1

The first object

Obj2

The second object

Simple

Only uses the class name, not the package or packages.

Returns:

Whether they have the same class name or not

statictoFloatArray(Data:String):Array<Float>

Split a comma-separated string into an array of floats

Parameters:

Data

string formatted like this: "1.0,2.1,5.6,1245587.9, -0.00354"

Returns:

An array of floats

statictoIntArray(Data:String):Array<Int>

Split a comma-separated string into an array of ints

Parameters:

Data

String formatted like this: "1, 2, 5, -10, 120, 27"

Returns:

An array of ints

statictoTitleCase(str:String):String

Returns a string formatted to 'Title Case'. Example: "a tale of two cities, pt ii" returns "A Tale of Two Cities, Part II"`

statictoUnderscoreCase(str:String):String

Returns an Underscored, or "slugified" string Example: "A Tale of Two Cities, Part II" becomes "a_tale_of_two_cities__part_ii"