Apache Flex 4.16.0 API Reference | All Packages | All Classes | Index | Frames No Frames |
NumberBase

Package | mx.formatters
Class | public class NumberBase
Inheritance | NumberBase Object

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

The NumberBase class is a utility class that contains general number formatting capabilities, including rounding, precision, thousands formatting, and negative sign formatting. The implementation of the formatter classes use this class.

See also

mx.formatters.NumberFormatter
mx.formatters.NumberBaseRoundType

Public Properties

| Property | Defined By
--- | --- | ---
|  | decimalSeparatorFrom : String Decimal separator character to use when parsing an input String. | NumberBase
|  | decimalSeparatorTo : String Decimal separator character to use when outputting formatted decimal numbers. | NumberBase
|  | isValid : Boolean = false If true, the format succeeded, otherwise it is false. | NumberBase
|  | thousandsSeparatorFrom : String Character to use as the thousands separator in the input String. | NumberBase
|  | thousandsSeparatorTo : String Character to use as the thousands separator in the output String. | NumberBase

Public Methods

| Method | Defined By
--- | --- | ---
|  | NumberBase(decimalSeparatorFrom:String = ., thousandsSeparatorFrom:String = ,, decimalSeparatorTo:String = ., thousandsSeparatorTo:String = ,) Constructor. | NumberBase
|  | expandExponents(value:String):String Formats a number in exponent notation, into a number in decimal notation. | NumberBase
|  | formatDecimal(value:String):String Formats a number by replacing the default decimal separator, ".", with the decimal separator specified by decimalSeparatorTo. | NumberBase
|  | formatNegative(value:String, useSign:Boolean):String Formats a negative number with either a minus sign (-) or parentheses (). | NumberBase
|  | formatPrecision(value:String, precision:int):String Formats a number by setting its decimal precision by using the decimalSeparatorTo property as the decimal separator. | NumberBase
|  | formatRounding(value:String, roundType:String):String Formats a number by rounding it. | NumberBase
|  | formatRoundingWithPrecision(value:String, roundType:String, precision:int):String Formats a number by rounding it and setting the decimal precision. | NumberBase
|  | formatThousands(value:String):String Formats a number by using the thousandsSeparatorTo property as the thousands separator and the decimalSeparatorTo property as the decimal separator. | NumberBase
|  | parseNumberString(str:String):String Extracts a number from a formatted String. | NumberBase

Property Detail

decimalSeparatorFrom | property

`public var decimalSeparatorFrom:String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Decimal separator character to use when parsing an input String.

The default value is `"."`.

decimalSeparatorTo | property |

`public var decimalSeparatorTo:String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Decimal separator character to use when outputting formatted decimal numbers.

The default value is `"."`.

isValid | property |

`public var isValid:Boolean = false`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

If `true`, the format succeeded, otherwise it is `false`.

thousandsSeparatorFrom | property |

`public var thousandsSeparatorFrom:String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Character to use as the thousands separator in the input String.

The default value is `","`.

thousandsSeparatorTo | property |

`public var thousandsSeparatorTo:String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Character to use as the thousands separator in the output String.

The default value is `","`.

Constructor Detail

NumberBase | () | Constructor

`public function NumberBase(decimalSeparatorFrom:String = ., thousandsSeparatorFrom:String = ,, decimalSeparatorTo:String = ., thousandsSeparatorTo:String = ,)`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Constructor.

Parameters

| `decimalSeparatorFrom:String` (default = `.`)`` — Decimal separator to use when parsing an input String.
| `thousandsSeparatorFrom:String` (default = `,`)`` — Character to use as the thousands separator in the input String.
| `decimalSeparatorTo:String` (default = `.`)`` — Decimal separator character to use when outputting formatted decimal numbers.
| `thousandsSeparatorTo:String` (default = `,`)`` — Character to use as the thousands separator in the output String.

Method Detail

expandExponents | () | method

`public function expandExponents(value:String):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number in exponent notation, into a number in decimal notation.

Parameters

| `value:String` — String to process in exponent notation.

Returns

| `String` — Formatted number.

formatDecimal | () | method |

`public function formatDecimal(value:String):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number by replacing the default decimal separator, ".", with the decimal separator specified by `decimalSeparatorTo`.

Parameters

| `value:String` — The String value of the Number (formatted American style ####.##).

Returns

| `String` — String representation of the input where "." is replaced with the decimal formatting character.

formatNegative | () | method |

`public function formatNegative(value:String, useSign:Boolean):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a negative number with either a minus sign (-) or parentheses ().

Parameters

| `value:String` — Value to be formatted.
| `useSign:Boolean` — If `true`, use a minus sign (-). If `false`, use parentheses ().

Returns

| `String` — Formatted number.

formatPrecision | () | method |

`public function formatPrecision(value:String, precision:int):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number by setting its decimal precision by using the `decimalSeparatorTo` property as the decimal separator.

Parameters

| `value:String` — Value to be formatted.
| `precision:int` — Number of decimal points to use.

Returns

| `String` — Formatted number.

formatRounding | () | method |

`public function formatRounding(value:String, roundType:String):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number by rounding it. The possible rounding types are defined by mx.formatters.NumberBaseRoundType.

Parameters

| `value:String` — Value to be rounded.
| `roundType:String` — The type of rounding to perform: NumberBaseRoundType.NONE, NumberBaseRoundType.UP, NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.

Returns

| `String` — Formatted number.

See also

mx.formatters.NumberBaseRoundType

formatRoundingWithPrecision | () | method |

`public function formatRoundingWithPrecision(value:String, roundType:String, precision:int):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number by rounding it and setting the decimal precision. The possible rounding types are defined by mx.formatters.NumberBaseRoundType.

Parameters

| `value:String` — Value to be rounded.
| `roundType:String` — The type of rounding to perform: NumberBaseRoundType.NONE, NumberBaseRoundType.UP, NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
| `precision:int` — int of decimal places to use.

Returns

| `String` — Formatted number.

See also

mx.formatters.NumberBaseRoundType

formatThousands | () | method |

`public function formatThousands(value:String):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Formats a number by using the `thousandsSeparatorTo` property as the thousands separator and the `decimalSeparatorTo` property as the decimal separator.

Parameters

| `value:String` — Value to be formatted.

Returns

| `String` — Formatted number.

parseNumberString | () | method |

`public function parseNumberString(str:String):String`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Extracts a number from a formatted String. Examines the String from left to right and returns the first number sequence. Ignores thousands separators and includes the decimal and numbers trailing the decimal.

Parameters

| `str:String` — String to parse for the numeric value.

Returns

| `String` — Value, which can be a decimal.

Sun Mar 5 2017, 03:42 PM +11:00