A few simple static functions used throughout the library
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
|
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
|
public static function humanReadableTime(milliseconds:Number):StringParameters
Returns
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
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
|
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
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
|
chris@acleveraddress.com - 2010