CoreData |
2 other children |
Provides facilities for data checking and conversion for all types of Flash data types. This includes more complex data operations such as string replacement, time, and currency management.
__/ REQUIREMENTS \__
ActionScript 3.0 (or later)
__/ IMPORTS \__
flash.utils.* flash.display.DisplayObjectContainer com.bnm.api.instances.ErrorBroadcast com.bnm.api.instances.TimeObject com.bnm.api.instances.Exception
__/ EXTENDS \__
com.bnm.api.CoreObject
__/ IMPLEMENTS \__
nothing
__/ NOTICE \__
©opyright 2008 Bay New Media. All rights, as stipulated in the The MIT License, are reserved.
This ActionScript library is licensed and released under the MIT License (http://www.opensource.org
Please visit http://www.baynewmedia.com/ or email con@baynewm edia.com for information, questions, concerns, or bug reports. tact
__/ NOTES \__
This class is commented using the NaturalDocs documentation system. It is intended to be easily read both from the direct source code and from an adaptation that is generated as hyperlinked HTML. The NaturalDocs specification used in this class’ documentation is version 1.35 though older versions may probably be used safely. For more information, please visit: http://www.naturaldocs.org/
The BNMAPI is officially available (primary sources) on Source Forge (http://sourceforge.net/projects/bnmapi/), on the Bay New Media site (http;//www.baynewmedia.com/), on the PeaBee project site (http://www.peabee.com/), and through the Bay New Media SVM repository server (visit http://www.baynewmedia.com/ for more information). Downloads from other sources may not be complete or up-to-date.
If you’re interested in joining the BNMAPI project in any capacity (development, testing, distribution, etc.), please visit us on Source Forge or the Bay New Media web site.
CoreData | Provides facilities for data checking and conversion for all types of Flash data types. |
Functions | |
CoreData | Constructor method for the class. |
valueExists | Checks whether or not the value in the parameter exists. |
newTimeObject | Returns an instance of a new TimeObject. |
newErrorBroadcast | Returns an instance of a new ErrorBroadcast object. |
replaceString | Replaces a source string (the meta string) in a given input sring with a new string. |
urlDecode | Decodes URL-encoded entities in the inut string to their actual values. |
toHexString | Converts the input string to its hexadecimal representation. |
toHexValue | Converts the input number to its hexadecimal string representation. |
fromHexValue | Converts the input number from its hexadecimal string representation to a number value. |
fromHexString | Converts the hexadecinal input string to its plain text value. |
toBinaryString | Converts the input number to its binary representation as a string. |
getBit | Returns the bit value at the specific position within the input number. |
setBit | Sets the bit at the specified position in the input number to the specified value. |
toDollarString | Converts an input number (integer or real) into a properly formatted dollar string in the format “$##.##” (more or less numbers are used for the dollar value depending on the size of the number). |
fromDollarString | Converts a string from a dollar string (such as one that would be created by the toDollarString method) and creates a number out of it. |
stripLeadingSpace | Strips the leading spaces from a string and returns the processed string. |
stripTrailingSpace | Strips the trailing spaces from a string and returns the processed string. |
stripOutsideSpace | Strips spaces from both the end and the beginning of the input string. |
splitVersionInfo | Splits a version string such as “2.1.5r12” to its constituent parts. |
public function valueExists( ... value ):Boolean
Checks whether or not the value in the parameter exists. If the parameter is an object type, it must be non-NULL and non-UNDEFINED for this method to return TRUE. If the object is a String, it must also not be an empty string. For numeric values, the parameter must be a number (or not NaN). If the value is of type Array, length must be longer than 0. For all other objects (generic or otherwise), a member variable or method of some sort must be detected, otherwise it is assumed to be empty. In summary, the object or reference must exist and must have some value.
value (untyped, optional): Any object or reference.
Boolean: TRUE if the parameter supplied is not NULL, UNDEFINED, a blank string if a String, and a proper number if a Number (or int/uint). Arrays must have a length greater than 0, and objects of all other kinds must have one or more member vazriables or methods. Otherwise, FALSE is returned.
nothing
nothing
no
public function newTimeObject( ... args ):TimeObject
Returns an instance of a new TimeObject. This method is provided for easy access only, no translation is done.
... args (untyped, optional): Any arguments that may be supplied to the TimeObject constructor.
TimeObject: An new instance of the TimeObject class.
nothing
nothing
no
public function newErrorBroadcast( ... args ):ErrorBroadcast
Returns an instance of a new ErrorBroadcast object. This method is provided for easy access only, no translation is done.
... args (untyped, optional): Any arguments that may be supplied to the ErrorBroadcast constructor.
ErrorBroadcast: An new instance of the ErrorBroadcast class.
nothing
nothing
no
public function replaceString( sourceString: *, targetString: *, metaString: * ):String
Replaces a source string (the meta string) in a given input sring with a new string. For example, in the string ‘Replace %this item’ and using the string ‘%this’ as a meta string and ‘that’ as the target string, the returned value will be ‘Replace that item’. Note that the meta string does not need to be preceeded by a percent sign (or any specific escape sequence for that matter). It can be any string.
sourceString (untyped, required): The input string containing one or more instances of the meta string to replace. If this value is not a string, a conversion will be attempted. targetString (untyped, required): The string that will replace the meta string instances in the output. If this value is not a string, a conversion will be attempted. metaString (untyped, required): The string that will be replaced with the target string in the output. If this value is not a string, a conversion will be attempted.
String: A copy of sourceString with every instance of the meta string replaced with the target string.
nothing
nothing
no
public function urlDecode( inString: String ):String
Decodes URL-encoded entities in the inut string to their actual values. This supports both standard escape sequences using numeric values (Flash <unescape> function) as well as non standard macro representations such as ‘"’. NOT ALL entities are supported but most often-used ones are.
inString (string, required): The URL-encoded string to decode.
string: The string in standard ISO-8859 text format.
nothing
nothing
no
public function toHexString( input: String ):String
Converts the input string to its hexadecimal representation. Each byte’s decinal value is converted to its hexadecimal value and the two-digit string is appended to the output. Values less than 10 have a 0 prepended to ensure correct re-translation (i.e. A = 0A). The input string “Hello” would become decimal 72+101+108+108+111 and hex 48+65+6C+6C+6F which is lumped together into the output string “48656C6C6F”. Due to this transformation, the output string will always be exactly twice the size of the input string.
input (string, required): The string to convert to its hexadecimal representation.
String: The hexadecimal representation of the input string, or UNDEFINED if there was a problem during conversion.
nothing
nothing
public function toHexValue( input: Number ):String
Converts the input number to its hexadecimal string representation. Because numbers in Flash are always 32 bits long, the output value will always be 8 hexadecimal characters long. This is very similar to the “0x######” format except that it contains an extra byte of information.
input (number, required): The number to convert to its hexadecimal string representation.
String: The hexadecimal representation of the input number, or UNDEFINED if there was a problem during conversion.
nothing
nothing
no
public function fromHexValue( input: String ):Number
Converts the input number from its hexadecimal string representation to a number value. Because numbers in Flash are always 32 bits long, the input string must always be 8 characters long.
input (string, required): The number to convert to its hexadecimal value representation.
Number: The numeric value represented by the input string. Undefined if the input value was not supplied.
nothing
nothing
no
public function fromHexString( input: String ):String
Converts the hexadecinal input string to its plain text value. This essentially reverses the operation of the toHexString method.
input (string, required): The string to convert to its plain text value.
String: The plain text value of the hexadecimal input string, or UNDEFINED if there was a problem during conversion.
nothing
nothing
no
public function toBinaryString ( inputNum: * ):String
Converts the input number to its binary representation as a string. Because all numbers are treated as 32-bit values in Flash, this will always result in a 32 character output string.
inputNum (Number, int, or uint, required): The string to convert to a 32-bit binary string sequence.
String: The 32 character representation of the input parameter’s binary value, or NULL if the inpur parameter was not a valid numeric type.
nothing
nothing
no
public function getBit( bitPos: Number, inputNum: Number ):Boolean
Returns the bit value at the specific position within the input number. The offset is 1-based so that 1 is the lowest position and 32 is the highest position.
bitPos (Number, required): The bit position to retrieve within the inputNum parameter. inputNum (Number, required): The number from which to extract the bit value. Always a 32-bit value.
Boolean: TRUE or FALSE depending on the bit value requested. This may be translated to 1 or 0 respectively. If the input parameters are out of range or not correctly typed, UNDEFINED is returned.
nothing
nothing
no
public function setBit( bitPos: Number, inputNum: Number, bitVal: Boolean )
Sets the bit at the specified position in the input number to the specified value.
bitPos (Number, required): The bit position to operate on within the inputNum parameter. This is 1 based so that a value of 1 refers to the first bit. inputNum (Number, required): The number within which to manipulate the bit value. bitVal (Boolean, required): The value to set the specifed bit to. TRUE or FALSE is translated to 1 and 0 respectively.
Number: The input value with the specified bit manipulated to the specified value.
nothing
nothing
no
public function toDollarString ( inp: Number, dollarSign: String ):String
Converts an input number (integer or real) into a properly formatted dollar string in the format “$##.##” (more or less numbers are used for the dollar value depending on the size of the number).
inp (number, required): The integer (whole) or real (decimal) number to convert into a dollar string. dollarSign (string, optional): The symbol to prepend to the string. Be default (if not supplied), this value is “$”.
string: The dollar value of the inp value in a properly formatted dollar format. A null string is returned if the inp parameter is not numeric or cannot be converted to a number.
nothing
nothing
no
public function fromDollarString ( inp: String ):*
Converts a string from a dollar string (such as one that would be created by the toDollarString method) and creates a number out of it. This is done by stripping out all non-numeric values with the exception of a period (if present). If more than one period is found, only the first period from the left is used to denote a decimal separator and remaining periods are stripped out.
inp (string, required): The dollar-formatted string to convert to a number value.
number: The numeric representation of the dollar string. A NULL value is returned if the `inp` paramater is not and cannot be converted into a string.
nothing
nothing
no
public function stripLeadingSpace( inputStr: String ):String
Strips the leading spaces from a string and returns the processed string.
inputStr (string, required): The string from which to strip the leading spaces. This string won’t itself be affected.
String: The inputStr string with all leading spaces stripped.
nothing
nothing
no
public function stripTrailingSpace( inputStr: String ):String
Strips the trailing spaces from a string and returns the processed string.
inputStr (string, required): The string from which to strip the trailing spaces. This string won’t itself be affected.
String: The inputStr string with all trailling spaces stripped.
nothing
nothing
no
public function stripOutsideSpace ( inputStr: String ):String
Strips spaces from both the end and the beginning of the input string. This produces the same result as calling stripTrailingSpace and stripLeadingSpace on a string.
inputStr (string, required): The string from which to strip the leading and trailing spaces. T this string won’t be affected.
String: The inputStr string with all leading and trailling spaces stripped.
nothing
nothing
no
public function splitVersionInfo( versionString: String ):Object
Splits a version string such as “2.1.5r12” to its constituent parts. Any values not specified in the parameter string are returned as NULL values otherwise they’re returned as int types. The format for the string is: “major.minor.sub R revision”.
versionString (string, required): The string to split up into version information pieces.
Object: An object containing version information, in pieces, as numeric int types. This includes the values: major (int): The major version number (first number in the dot series). minor (int): The number after the first period in the series. May be NULL if not specified. sub (int): The number after the second period in the series. May be NULL if not specified. revision (int): Any number after an “r” or “R” designator in the version series, or NULL if not specified.
nothing
nothing
no
Constructor method for the class.
public function CoreData()
Checks whether or not the value in the parameter exists.
public function valueExists( ... value ):Boolean
Returns an instance of a new TimeObject.
public function newTimeObject( ... args ):TimeObject
Returns an instance of a new ErrorBroadcast object.
public function newErrorBroadcast( ... args ):ErrorBroadcast
Replaces a source string (the meta string) in a given input sring with a new string.
public function replaceString( sourceString: *, targetString: *, metaString: * ):String
Decodes URL-encoded entities in the inut string to their actual values.
public function urlDecode( inString: String ):String
Converts the input string to its hexadecimal representation.
public function toHexString( input: String ):String
Converts the input number to its hexadecimal string representation.
public function toHexValue( input: Number ):String
Converts the input number from its hexadecimal string representation to a number value.
public function fromHexValue( input: String ):Number
Converts the hexadecinal input string to its plain text value.
public function fromHexString( input: String ):String
Converts the input number to its binary representation as a string.
public function toBinaryString ( inputNum: * ):String
Returns the bit value at the specific position within the input number.
public function getBit( bitPos: Number, inputNum: Number ):Boolean
Sets the bit at the specified position in the input number to the specified value.
public function setBit( bitPos: Number, inputNum: Number, bitVal: Boolean )
Converts an input number (integer or real) into a properly formatted dollar string in the format “$##.##” (more or less numbers are used for the dollar value depending on the size of the number).
public function toDollarString ( inp: Number, dollarSign: String ):String
Converts a string from a dollar string (such as one that would be created by the toDollarString method) and creates a number out of it.
public function fromDollarString ( inp: String ):*
Strips the leading spaces from a string and returns the processed string.
public function stripLeadingSpace( inputStr: String ):String
Strips the trailing spaces from a string and returns the processed string.
public function stripTrailingSpace( inputStr: String ):String
Strips spaces from both the end and the beginning of the input string.
public function stripOutsideSpace ( inputStr: String ):String
Splits a version string such as “2.1.5r12” to its constituent parts.
public function splitVersionInfo( versionString: String ):Object