class flixel.util.FlxStringUtil

Available on all platforms

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

Class Fields

static function arrayToCSV(Data:Array<Int>, Width:Int, ?Invert:Bool = false):String

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

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.

static function bitmapToCSV(Bitmap:BitmapData, ?Invert:Bool = false, ?Scale:Int = 1, ?ColorMap:Array<Int> = null):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. * *

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 (0xAARRGGBB) 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.

static function filterDigits(Input:String):String

Takes a string and filters out everything but the digits. * *

Input

The input string *

returns

The output string, digits-only

static function formatArray(AnyArray:Array<Dynamic>):String

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

AnyArray

Any Array object. *

returns

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

static function formatMoney(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 var results:String = FlxString.formatMoney(10,false); * However, very handy for displaying large sums or decimal money values. * *

Amount

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

ShowDecimal

Whether to show the decimals/cents component. Default value is true. *

EnglishStyle

Major quantities (thousands, millions, etc) separated by commas, and decimal by a period. Default value is true. *

returns

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

static function formatStringMap(AnyMap:Map<String, Dynamic>):String

Generate a comma-seperated string representation of the keys of a StringMap. * *

AnyMap

A StringMap object. *

returns

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

static function formatTicks(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. * *

StartTicks

The first timestamp from the system. *

EndTicks

The second timestamp from the system. *

returns

A String containing the formatted time elapsed information.

static function formatTime(Seconds:Float, ?ShowMS:Bool = false):String

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

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".

static function getClassName(Obj:Dynamic, ?Simple:Bool = false):String

Get the String name of any Object. * *

Obj

The object in question. *

Simple

Returns only the class name, not the package or packages. *

returns

The name of the Class as a String object.

static function getDebugString(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) * *

LabelValuePairs

Array with the data for the string

static function getDomain(url:String):String

Returns the domain of a URL.

static function htmlFormat(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. * *

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.

static function imageToCSV(ImageFile:Dynamic, ?Invert:Bool = false, ?Scale:Int = 1):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. * *

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. *

returns

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

static function sameClassName(Obj1:Dynamic, Obj2:Dynamic, ?Simple:Bool = true):Bool

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

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

static function toFloatArray(Data:String):Array<Float>

Split a comma-separated string into an array of floats * *

Data

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

returns

An array of floats

static function toIntArray(Data:String):Array<Int>

Split a comma-separated string into an array of ints * *

Data

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

returns

An array of ints