Packagecom.acleveraddress.net.multi_loader.utils
Classpublic class FormatUtils

A few simple static functions used throughout the library



Public Methods
 MethodDefined by
  
addCacheBuster(path:String):String
[static] Adds a randomised querystring string to an existing path to avoid downloading a cached version
FormatUtils
  
humanReadableBytes(bytes:Number):String
[static] Takes the number of bytes and converts it to a readable string
FormatUtils
  
humanReadableTime(milliseconds:Number):String
[static]
FormatUtils
  
pow(base:Number, exp:int):Number
[static] A speedy way to do Math.pow(x,y)
FormatUtils
  
roundDecimalToPlaces(n:Number, places:uint):Number
[static] Rounds a number to a set number of places
FormatUtils
  
tidyPercentage(n:Number):String
[static] Ensures a percentage is fixed width as a string, accouting for the MultiLoader.percentageScale
FormatUtils
  
truncateString(str:String, len:uint):String
[static] Cuts the middle of a string to make it the required length and adds a "..." in the middle, if necessary
FormatUtils
Method detail
addCacheBuster()method
public static function addCacheBuster(path:String):String

Adds a randomised querystring string to an existing path to avoid downloading a cached version

Parameters
path:String — The path to update

Returns
String — The updated path
humanReadableBytes()method 
public static function humanReadableBytes(bytes:Number):String

Takes the number of bytes and converts it to a readable string

Parameters
bytes:Number — Number of bytes

Returns
String — A human readable string representation of the number of bytes
humanReadableTime()method 
public static function humanReadableTime(milliseconds:Number):StringParameters
milliseconds:Number

Returns
String
pow()method 
public static function pow(base:Number, exp:int):Number

A speedy way to do Math.pow(x,y)

Parameters
base:Number — A number to be raised to a power
 
exp:int — A number specifying a power the parameter base is raised to

Returns
Number — base^exp
roundDecimalToPlaces()method 
public static function roundDecimalToPlaces(n:Number, places:uint):Number

Rounds a number to a set number of places

Parameters
n:Number — The number to be rounded
 
places:uint — The number of decimal places to round n to

Returns
Number — The rounded number
tidyPercentage()method 
public static function tidyPercentage(n:Number):String

Ensures a percentage is fixed width as a string, accouting for the MultiLoader.percentageScale

Parameters
n:Number — The percentage to convert

Returns
String — The percentage (n) as a 4 character string

See also

com.research_now.net.multi_loader.MultiLoader.percentageScale
truncateString()method 
public static function truncateString(str:String, len:uint):String

Cuts the middle of a string to make it the required length and adds a "..." in the middle, if necessary

Parameters
str:String — The string to truncate
 
len:uint — The length required

Returns
String — The resulting string, or the original if it was already within the necessary bounds