This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new d811724  Fix MX NumberFormatter to be usable in MX components
d811724 is described below

commit d811724a7d229189f668366e7ab4eabfeda0e585
Author: Piotr Zarzycki <[email protected]>
AuthorDate: Mon Oct 14 18:18:10 2019 +0200

    Fix MX NumberFormatter to be usable in MX components
    
    (reference #472 )
---
 .../src/main/royale/mx/formatters/NumberBase.as    | 1162 ++++++++++----------
 .../main/royale/mx/formatters/NumberFormatter.as   | 1113 ++++++++++---------
 2 files changed, 1137 insertions(+), 1138 deletions(-)

diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberBase.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberBase.as
index 0911841..4e8aeb7 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberBase.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberBase.as
@@ -20,651 +20,651 @@
 package mx.formatters
 {
 
-/**
- *  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 mx.formatters.NumberFormatter
- *  @see mx.formatters.NumberBaseRoundType
- *  
- *  @langversion 3.0
- *  @playerversion Flash 9
- *  @playerversion AIR 1.1
- *  @productversion Flex 3
- */
-public class NumberBase
-{
-    // include "../core/Version.as";
-
-       
//--------------------------------------------------------------------------
-       //
-       //  Constructor
-       //
-       
//--------------------------------------------------------------------------
-
        /**
-        *  Constructor.
-        * 
-        *  @param decimalSeparatorFrom Decimal separator to use
-        *  when parsing an input String.
-        *
-        *  @param thousandsSeparatorFrom Character to use
-        *  as the thousands separator in the input String.
+        *  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.
         *
-        *  @param decimalSeparatorTo Decimal separator character to use
-        *  when outputting formatted decimal numbers.
+        *  @see mx.formatters.NumberFormatter
+        *  @see mx.formatters.NumberBaseRoundType
         *
-        *  @param thousandsSeparatorTo Character to use
-        *  as the thousands separator in the output String.
-        *  
         *  @langversion 3.0
         *  @playerversion Flash 9
         *  @playerversion AIR 1.1
         *  @productversion Flex 3
         */
-       public function NumberBase(decimalSeparatorFrom:String = ".",
-                                                          
thousandsSeparatorFrom:String = ",",
-                                                          
decimalSeparatorTo:String = ".",
-                                                          
thousandsSeparatorTo:String = ",")
+       public class NumberBase
        {
-               super();
+               // include "../core/Version.as";
+
+               
//--------------------------------------------------------------------------
+               //
+               //  Constructor
+               //
+               
//--------------------------------------------------------------------------
+
+               /**
+                *  Constructor.
+                *
+                *  @param decimalSeparatorFrom Decimal separator to use
+                *  when parsing an input String.
+                *
+                *  @param thousandsSeparatorFrom Character to use
+                *  as the thousands separator in the input String.
+                *
+                *  @param decimalSeparatorTo Decimal separator character to use
+                *  when outputting formatted decimal numbers.
+                *
+                *  @param thousandsSeparatorTo Character to use
+                *  as the thousands separator in the output String.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function NumberBase(decimalSeparatorFrom:String = ".",
+                                                                  
thousandsSeparatorFrom:String = ",",
+                                                                  
decimalSeparatorTo:String = ".",
+                                                                  
thousandsSeparatorTo:String = ",")
+               {
+                       super();
 
-               this.decimalSeparatorFrom = decimalSeparatorFrom;
-               this.thousandsSeparatorFrom = thousandsSeparatorFrom;
-               this.decimalSeparatorTo = decimalSeparatorTo;
-               this.thousandsSeparatorTo = thousandsSeparatorTo;
+                       this.decimalSeparatorFrom = decimalSeparatorFrom;
+                       this.thousandsSeparatorFrom = thousandsSeparatorFrom;
+                       this.decimalSeparatorTo = decimalSeparatorTo;
+                       this.thousandsSeparatorTo = thousandsSeparatorTo;
 
-               isValid = true;
-       }
+                       isValid = true;
+               }
 
-       
//--------------------------------------------------------------------------
-       //
-       //  Properties
-       //
-       
//--------------------------------------------------------------------------
+               
//--------------------------------------------------------------------------
+               //
+               //  Properties
+               //
+               
//--------------------------------------------------------------------------
+
+               //----------------------------------
+               //  decimalSeparatorFrom
+               //----------------------------------
+
+               private var _decimalSeparatorFrom:String;
+
+               /**
+                *  Decimal separator character to use
+                *  when parsing an input String.
+                *
+                *  @default "."
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function get decimalSeparatorFrom():String
+               {
+                       return _decimalSeparatorFrom;
+               }
+               public function set decimalSeparatorFrom(value:String):void
+               {
+                       _decimalSeparatorFrom = value;
+               }
 
-       //----------------------------------
-       //  decimalSeparatorFrom
-       //----------------------------------
+               //----------------------------------
+               //  decimalSeparatorTo
+               //----------------------------------
+
+               private var _decimalSeparatorTo:String;
+               /**
+                *  Decimal separator character to use
+                *  when outputting formatted decimal numbers.
+                *
+                *  @default "."
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function get decimalSeparatorTo():String
+               {
+                       return _decimalSeparatorTo;
+               }
+               public function set decimalSeparatorTo(value:String):void
+               {
+                       _decimalSeparatorTo = value;
+               }
 
-    private var _decimalSeparatorFrom:String;
-    
-       /**
-     *  Decimal separator character to use
-        *  when parsing an input String.
-        *  
-        *  @default "."
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function get decimalSeparatorFrom():String
-    {
-        return _decimalSeparatorFrom;
-    }
-    public function set decimalSeparatorFrom(value:String):void
-    {
-        _decimalSeparatorFrom = value;
-    }
-
-       //----------------------------------
-       //  decimalSeparatorTo
-       //----------------------------------
-
-    private var _decimalSeparatorTo:String;
-       /**
-     *  Decimal separator character to use
-        *  when outputting formatted decimal numbers.
-        *  
-        *  @default "."
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function get decimalSeparatorTo():String
-    {
-        return _decimalSeparatorTo;
-    }
-    public function set decimalSeparatorTo(value:String):void
-    {
-        _decimalSeparatorTo = value;
-    }
-
-       //----------------------------------
-       //  isValid
-       //----------------------------------
-
-    private var _isValid:Boolean = false;
-    
-       /**
-        *  If <code>true</code>, the format succeeded,
-        *  otherwise it is <code>false</code>.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function get isValid():Boolean
-    {
-        return _isValid;
-    }
-    public function set isValid(value:Boolean):void
-    {
-        _isValid = value;
-    }
-
-       //----------------------------------
-       //  thousandsSeparatorFrom
-       //----------------------------------
-
-    private var _thousandsSeparatorFrom:String;
-    
-       /**
-     *  Character to use as the thousands separator
-        *  in the input String.
-        *  
-        *  @default ","
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function get thousandsSeparatorFrom():String
-    {
-        return _thousandsSeparatorFrom;
-    }
-    public function set thousandsSeparatorFrom(value:String):void
-    {
-        _thousandsSeparatorFrom = value;
-    }
-
-       //----------------------------------
-       //  thousandsSeparatorTo
-       //----------------------------------
-
-    private var _thousandsSeparatorTo:String;
-    
-       /**
-     *  Character to use as the thousands separator
-        *  in the output String.
-        *  
-        *  @default ","
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function get thousandsSeparatorTo():String
-    {
-        return _thousandsSeparatorTo;
-    }
-    
-    public function set thousandsSeparatorTo(value:String):void
-    {
-        _thousandsSeparatorTo = value;
-    }
-
-       
//--------------------------------------------------------------------------
-       //
-       //  Methods
-       //
-       
//--------------------------------------------------------------------------
+               //----------------------------------
+               //  isValid
+               //----------------------------------
+
+               private var _isValid:Boolean = false;
+
+               /**
+                *  If <code>true</code>, the format succeeded,
+                *  otherwise it is <code>false</code>.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function get isValid():Boolean
+               {
+                       return _isValid;
+               }
+               public function set isValid(value:Boolean):void
+               {
+                       _isValid = value;
+               }
 
-       /**
-        *  Formats a number by rounding it. 
-        *  The possible rounding types are defined by
-        *  mx.formatters.NumberBaseRoundType.
-        *
-        *  @param value Value to be rounded.
-        *
-        *  @param roundType The type of rounding to perform:
-        *  NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
-        *  NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
-        *
-        *  @return Formatted number.
-        *
-        *  @see mx.formatters.NumberBaseRoundType
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatRounding(value:String, roundType:String):String
-       {
-               var v:Number = Number(value);
-               
-               if (roundType != NumberBaseRoundType.NONE)
+               //----------------------------------
+               //  thousandsSeparatorFrom
+               //----------------------------------
+
+               private var _thousandsSeparatorFrom:String;
+
+               /**
+                *  Character to use as the thousands separator
+                *  in the input String.
+                *
+                *  @default ","
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function get thousandsSeparatorFrom():String
                {
-                       if (roundType == NumberBaseRoundType.UP)
-                       {
-                                v = Math.ceil(v);
-                       }
-                       else if (roundType == NumberBaseRoundType.DOWN)
+                       return _thousandsSeparatorFrom;
+               }
+               public function set thousandsSeparatorFrom(value:String):void
+               {
+                       _thousandsSeparatorFrom = value;
+               }
+
+               //----------------------------------
+               //  thousandsSeparatorTo
+               //----------------------------------
+
+               private var _thousandsSeparatorTo:String;
+
+               /**
+                *  Character to use as the thousands separator
+                *  in the output String.
+                *
+                *  @default ","
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function get thousandsSeparatorTo():String
+               {
+                       return _thousandsSeparatorTo;
+               }
+
+               public function set thousandsSeparatorTo(value:String):void
+               {
+                       _thousandsSeparatorTo = value;
+               }
+
+               
//--------------------------------------------------------------------------
+               //
+               //  Methods
+               //
+               
//--------------------------------------------------------------------------
+
+               /**
+                *  Formats a number by rounding it.
+                *  The possible rounding types are defined by
+                *  mx.formatters.NumberBaseRoundType.
+                *
+                *  @param value Value to be rounded.
+                *
+                *  @param roundType The type of rounding to perform:
+                *  NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
+                *  NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
+                *
+                *  @return Formatted number.
+                *
+                *  @see mx.formatters.NumberBaseRoundType
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatRounding(value:String, 
roundType:String):String
+               {
+                       var v:Number = Number(value);
+
+                       if (roundType != NumberBaseRoundType.NONE)
                        {
-                               v = Math.floor(v);
+                               if (roundType == NumberBaseRoundType.UP)
+                               {
+                                        v = Math.ceil(v);
+                               }
+                               else if (roundType == NumberBaseRoundType.DOWN)
+                               {
+                                       v = Math.floor(v);
+                               }
+                               else if (roundType == 
NumberBaseRoundType.NEAREST)
+                               {
+                                       v = Math.round(v);
+                               }
+                               else
+                               {
+                                       isValid = false;
+                                       return "";
+                               }
                        }
-                       else if (roundType == NumberBaseRoundType.NEAREST)
+
+                       return v.toString();
+               }
+
+               /**
+                *  Formats a number by rounding it and setting the decimal 
precision.
+                *  The possible rounding types are defined by
+                *  mx.formatters.NumberBaseRoundType.
+                *
+                *  @param value Value to be rounded.
+                *
+                *  @param roundType The type of rounding to perform:
+                *  NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
+                *  NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
+                *
+                *  @param precision int of decimal places to use.
+                *
+                *  @return Formatted number.
+                *
+                *  @see mx.formatters.NumberBaseRoundType
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatRoundingWithPrecision(value:String, 
roundType:String,
+                                                                               
                        precision:int):String
+               {
+                       // precision works differently now. Its default value 
is -1
+                       // which means 'do not alter the number's precision'. 
If a precision
+                       // value is set, all numbers will contain that 
precision. Otherwise, there
+                       // precision will not be changed.
+
+                       var v:Number = Number(value);
+
+                       // If rounding is not present and precision is NaN,
+                       // leave value untouched.
+                       if (roundType == NumberBaseRoundType.NONE)
                        {
-                               v = Math.round(v);
+                               if (precision == -1)
+                                       return v.toString();
                        }
                        else
                        {
-                               isValid = false;
-                               return "";
+                               // If rounding is present but precision is less 
than 0,
+                               // then do integer rounding.
+                               if (precision < 0)
+                                       precision = 0;
+
+                               // Shift decimal right as Math functions
+                               // perform only integer ceil/round/floor.
+                               v = v * Math.pow(10, precision);
+
+                               // Attempt to get rid of floating point errors
+                               v = Number(v.toString());
+                               if (roundType == NumberBaseRoundType.UP)
+                               {
+                                       v = Math.ceil(v);
+                               }
+                               else if (roundType == NumberBaseRoundType.DOWN)
+                               {
+                                       v = Math.floor(v);
+                               }
+                               else if (roundType == 
NumberBaseRoundType.NEAREST)
+                               {
+                                       v = Math.round(v);
+                               }
+                               else
+                               {
+                                       isValid = false;
+                                       return "";
+                               }
+
+                               // Shift decimal left to get back decimal to 
original point.
+                               v = v / Math.pow(10, precision);
                        }
+
+                       return v.toString();
                }
 
-               return v.toString();
-       }
+               /**
+                *  Formats a number by replacing the default decimal 
separator, ".",
+                *  with the decimal separator specified by 
<code>decimalSeparatorTo</code>.
+                *
+                *  @param value The String value of the Number
+                *  (formatted American style ####.##).
+                *
+                *  @return String representation of the input where "." is 
replaced
+                *  with the decimal formatting character.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatDecimal(value:String):String
+               {
+                       var parts:Array = value.split(".");
+                       return parts.join(decimalSeparatorTo);
+               }
 
-       /**
-        *  Formats a number by rounding it and setting the decimal precision.
-        *  The possible rounding types are defined by
-        *  mx.formatters.NumberBaseRoundType.
-        *
-        *  @param value Value to be rounded.
-        *
-        *  @param roundType The type of rounding to perform:
-        *  NumberBaseRoundType.NONE, NumberBaseRoundType.UP,
-        *  NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
-        *
-        *  @param precision int of decimal places to use.
-        *
-        *  @return Formatted number.
-        *
-        *  @see mx.formatters.NumberBaseRoundType
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatRoundingWithPrecision(value:String, 
roundType:String,
-                                                                               
                precision:int):String
-       {
-               // precision works differently now. Its default value is -1
-               // which means 'do not alter the number's precision'. If a 
precision
-               // value is set, all numbers will contain that precision. 
Otherwise, there
-               // precision will not be changed. 
-
-               var v:Number = Number(value);
-               
-               // If rounding is not present and precision is NaN,
-               // leave value untouched.
-               if (roundType == NumberBaseRoundType.NONE) 
+               /**
+                *  Formats a number by using
+                *  the <code>thousandsSeparatorTo</code> property as the 
thousands separator
+                *  and the <code>decimalSeparatorTo</code> property as the 
decimal separator.
+                *
+                *  @param value Value to be formatted.
+                *
+                *  @return Formatted number.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatThousands(value:String):String
                {
-                       if (precision == -1)
-                               return v.toString();
+                       var v:Number = Number(value);
+
+                       var isNegative:Boolean = (v < 0);
+
+                       var numStr:String = Math.abs(v).toString();
+
+                       numStr.toLowerCase();
+                       var e:int = numStr.indexOf("e")
+                       if (e != -1)  //deal with exponents
+                               numStr = expandExponents(numStr);
+
+                       var numArr:Array =
+                               
numStr.split((numStr.indexOf(decimalSeparatorTo) != -1) ? decimalSeparatorTo : 
".");
+                       var numLen:int = String(numArr[0]).length;
+
+                       if (numLen > 3)
+                       {
+                               var numSep:int = int(Math.floor(numLen / 3));
+
+                               if ((numLen % 3) == 0)
+                                       numSep--;
+
+                               var b:int = numLen;
+                               var a:int = b - 3;
+
+                               var arr:Array = [];
+                               for (var i:int = 0; i <= numSep; i++)
+                               {
+                                       arr[i] = numArr[0].slice(a, b);
+                                       a = int(Math.max(a - 3, 0));
+                                       b = int(Math.max(b - 3, 1));
+                               }
+
+                               arr.reverse();
+
+                               numArr[0] = arr.join(thousandsSeparatorTo);
+                       }
+
+                       numStr = numArr.join(decimalSeparatorTo);
+
+                       if (isNegative)
+                               numStr = "-" + numStr;
+
+                       return numStr.toString();
                }
-               else
+
+               /**
+                *  Formats a number by setting its decimal precision by using
+                *  the <code>decimalSeparatorTo</code> property as the decimal 
separator.
+                *
+                *  @param value Value to be formatted.
+                *
+                *  @param precision Number of decimal points to use.
+                *
+                *  @return Formatted number.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatPrecision(value:String, 
precision:int):String
                {
-                       // If rounding is present but precision is less than 0,
-                       // then do integer rounding.
-                       if (precision < 0) 
-                               precision = 0;
-                       
-                       // Shift decimal right as Math functions
-                       // perform only integer ceil/round/floor.
-                       v = v * Math.pow(10, precision);
-                       
-                       // Attempt to get rid of floating point errors
-                       v = Number(v.toString()); 
-                       if (roundType == NumberBaseRoundType.UP)
+                       // precision works differently now. Its default value 
is -1
+                       // which stands for 'do not alter the number's 
precision'. If a precision
+                       // value is set, all numbers will contain that 
precision. Otherwise, there
+                       // precision will not be changed.
+
+                       if (precision == -1)
+                               return value;
+
+                       var numArr:Array = value.split(decimalSeparatorTo);
+
+                       numArr[0] = numArr[0].length == 0 ? "0" : numArr[0];
+
+                       if (precision > 0)
                        {
-                               v = Math.ceil(v);
+                               var decimalVal:String = numArr[1] ? 
String(numArr[1]) : "";
+                               var fraction:String =
+                                       decimalVal + 
"000000000000000000000000000000000";
+                               value = numArr[0] + decimalSeparatorTo + 
fraction.substr(0, precision);
                        }
-                       else if (roundType == NumberBaseRoundType.DOWN)
+                       else
                        {
-                               v = Math.floor(v);
+                               value = String(numArr[0]);
                        }
-                       else if (roundType == NumberBaseRoundType.NEAREST)
+
+                       return value.toString();
+               }
+
+               /**
+                *  Formats a negative number with either a minus sign (-)
+                *  or parentheses ().
+                *
+                *  @param value Value to be formatted.
+                *
+                *  @param useSign If <code>true</code>, use a minus sign (-).
+                *  If <code>false</code>, use parentheses ().
+                *
+                *  @return Formatted number.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function formatNegative(value:String, 
useSign:Boolean):String
+               {
+                       if (useSign)
                        {
-                               v = Math.round(v);
+                               if (value.charAt(0) != "-")
+                                       value = "-" + value;
+                       }
+                       else if (!useSign)
+                       {
+                               if (value.charAt(0) == "-")
+                                       value = value.substr(1, value.length - 
1);
+                               value = "(" + value + ")";
                        }
                        else
                        {
                                isValid = false;
                                return "";
                        }
-                       
-                       // Shift decimal left to get back decimal to original 
point.
-                       v = v / Math.pow(10, precision); 
+                       return value;
                }
 
-               return v.toString();
-       }
-
-       /**
-        *  Formats a number by replacing the default decimal separator, ".", 
-        *  with the decimal separator specified by 
<code>decimalSeparatorTo</code>. 
-        *
-        *  @param value The String value of the Number
-        *  (formatted American style ####.##).
-        *
-        *  @return String representation of the input where "." is replaced
-        *  with the decimal formatting character.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatDecimal(value:String):String
-       {
-           var parts:Array = value.split(".");
-           return parts.join(decimalSeparatorTo);
-       }
-
-       /**
-        *  Formats a number by using 
-        *  the <code>thousandsSeparatorTo</code> property as the thousands 
separator 
-        *  and the <code>decimalSeparatorTo</code> property as the decimal 
separator.
-        *
-        *  @param value Value to be formatted.
-        *
-        *  @return Formatted number.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatThousands(value:String):String
-       {
-               var v:Number = Number(value);
-               
-               var isNegative:Boolean = (v < 0);
-               
-               var numStr:String = Math.abs(v).toString();
-               
-               numStr.toLowerCase();
-        var e:int = numStr.indexOf("e")
-        if (e != -1)  //deal with exponents
-            numStr = expandExponents(numStr);
-            
-               var numArr:Array =
-                       numStr.split((numStr.indexOf(decimalSeparatorTo) != -1) 
? decimalSeparatorTo : ".");
-               var numLen:int = String(numArr[0]).length;
-
-               if (numLen > 3)
+               /**
+                *  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.
+                *
+                *  @param str String to parse for the numeric value.
+                *
+                *  @return Value, which can be a decimal.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function parseNumberString(str:String):String
                {
-                       var numSep:int = int(Math.floor(numLen / 3));
-
-                       if ((numLen % 3) == 0)
-                               numSep--;
-                       
-                       var b:int = numLen;
-                       var a:int = b - 3;
-                       
-                       var arr:Array = [];
-                       for (var i:int = 0; i <= numSep; i++)
+                       // Check the decimal and thousands formatting for 
validity.
+                       var splitDec:Array = str.split(decimalSeparatorFrom);
+                       if (splitDec.length > 2)
+                               return null;
+
+                       // Attempt to extract the first number sequence from 
the string.
+                       var len:int = str.length;
+                       var count:int = 0;
+                       var letter:String;
+                       var num:String;
+                       var isNegative:Boolean = false;
+                       var hasExponent:Boolean = false;
+
+                       while (count < len)
                        {
-                               arr[i] = numArr[0].slice(a, b);
-                               a = int(Math.max(a - 3, 0));
-                               b = int(Math.max(b - 3, 1));
-                       }
-                       
-                       arr.reverse();
-                       
-                       numArr[0] = arr.join(thousandsSeparatorTo);
-               }
-               
-               numStr = numArr.join(decimalSeparatorTo);
-               
-               if (isNegative)
-                       numStr = "-" + numStr;
-               
-               return numStr.toString();
-       }
+                               letter = str.charAt(count);
+                               count++;
 
-       /**
-        *  Formats a number by setting its decimal precision by using 
-        *  the <code>decimalSeparatorTo</code> property as the decimal 
separator.
-        *
-        *  @param value Value to be formatted.
-        *
-        *  @param precision Number of decimal points to use.
-        *
-        *  @return Formatted number.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatPrecision(value:String, precision:int):String
-       {
-               // precision works differently now. Its default value is -1
-               // which stands for 'do not alter the number's precision'. If a 
precision
-               // value is set, all numbers will contain that precision. 
Otherwise, there
-               // precision will not be changed.
-               
-               if (precision == -1)
-                       return value;
-               
-               var numArr:Array = value.split(decimalSeparatorTo);
-               
-               numArr[0] = numArr[0].length == 0 ? "0" : numArr[0];
-               
-               if (precision > 0)
-               {
-                       var decimalVal:String = numArr[1] ? String(numArr[1]) : 
"";
-                       var fraction:String =
-                               decimalVal + 
"000000000000000000000000000000000";
-                       value = numArr[0] + decimalSeparatorTo + 
fraction.substr(0, precision);
-               }
-               else
-               {
-                       value = String(numArr[0]);
-               }
-               
-               return value.toString();
-       }
+                               if (("0" <= letter && letter <= "9") || (letter 
== decimalSeparatorFrom))
+                               {
+                                       var lastLetter:String = 
str.charAt(count - 2);
+                                       // We must handle cases where we have 
negative input like "-YTL5.000,00"
+                                       // and currencySymbol is longer than 
one character.
+                                       if ((lastLetter == "-") || 
(str.charAt(0) == "-"))
+                                               isNegative = true;
+                                       num = "";
+                                       count--;
+
+                                       for (var i:int = count; i < len; i++)
+                                       {
+                                               letter = str.charAt(count);
+                                               count++;
+                                               if ("0" <= letter && letter <= 
"9")
+                                               {
+                                                       num += letter;
+                                               }
+                                               else if (letter == 
decimalSeparatorFrom)
+                                               {
+                                                       num += ".";
+                                               }
+                                               else if (letter == "e" || 
letter == "E")
+                                               {
+                                                       num += letter;
+                                                       hasExponent = true;
+                                               }
+                                               else if (hasExponent && (letter 
== "-" || letter == "+"))
+                                               {
+                                                       num += letter;
+                                               }
+                                               else if (letter != 
thousandsSeparatorFrom || count >= len)
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
 
-       /**
-        *  Formats a negative number with either a minus sign (-)
-        *  or parentheses ().
-        *
-        *  @param value Value to be formatted.
-        *
-        *  @param useSign If <code>true</code>, use a minus sign (-).
-        *  If <code>false</code>, use parentheses ().
-        *
-        *  @return Formatted number.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function formatNegative(value:String, useSign:Boolean):String
-       {
-               if (useSign)
-               {
-                       if (value.charAt(0) != "-")
-                               value = "-" + value;
-               }
-               else if (!useSign)
-               {
-                       if (value.charAt(0) == "-")
-                               value = value.substr(1, value.length - 1);
-                       value = "(" + value + ")";
-               }
-               else
-               {
-                       isValid = false;
-                       return "";
-               }
-               return value;
-       }
+                       // there are all sorts of variations of zero, such as:
+                       // .0    0.   0.0    0000     0000.00000     -0
+                       // Here, we simply convert to a 'real' Number and see if
+                       // it's resolved to zero. if it does, just return a zero
+                       // string and be done with it.
+                       if ((num != null) && (str != ''))
+                       {
+                               var n:Number = Number(num);
 
-       /**
-        *  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.
-        *
-        *  @param str String to parse for the numeric value.
-        *
-        *  @return Value, which can be a decimal.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 9
-        *  @playerversion AIR 1.1
-        *  @productversion Flex 3
-        */
-       public function parseNumberString(str:String):String
-       {       
-               // Check the decimal and thousands formatting for validity.
-               var splitDec:Array = str.split(decimalSeparatorFrom);
-               if (splitDec.length > 2)
-                       return null;
-
-               // Attempt to extract the first number sequence from the string.
-               var len:int = str.length;
-               var count:int = 0;
-               var letter:String;
-               var num:String;
-               var isNegative:Boolean = false;
-               var hasExponent:Boolean = false
-
-               while (count < len)
-               {
-                       letter = str.charAt(count);
-                       count++;
+                               if (n == 0)
+                                       return '0';
+                       }
 
-                       if (("0" <= letter && letter <= "9") || (letter == 
decimalSeparatorFrom))
+                       // if the last digit is the dot, whack it
+                       if (num)
                        {
-                               var lastLetter:String = str.charAt(count - 2);
-                               // We must handle cases where we have negative 
input like "-YTL5.000,00"
-                               // and currencySymbol is longer than one 
character.
-                               if ((lastLetter == "-") || (str.charAt(0) == 
"-"))
-                                       isNegative = true;
-                               num = "";
-                               count--;
-                               
-                               for (var i:int = count; i < len; i++)
+                               if (num.charAt(num.length-1) == '.')
                                {
-                                       letter = str.charAt(count);
-                                       count++;
-                                       if ("0" <= letter && letter <= "9")
-                                       {
-                                               num += letter;
-                                       }
-                                       else if (letter == decimalSeparatorFrom)
-                                       {
-                                               num += ".";
-                                       }
-                                       else if (letter == "e" || letter == "E")
-                                       {
-                                               num += letter;
-                                               hasExponent = true;
-                                       }
-                                       else if (hasExponent && (letter == "-" 
|| letter == "+"))
+                                       // we have something like 33.
+                                       if (num.length >= 2)
                                        {
-                                               num += letter;
+                                               num = num.substring(0, 
num.length-1);
                                        }
-                                       else if (letter != 
thousandsSeparatorFrom || count >= len)
+                                       // we have merely .
+                                       else if (num.length == 1)
                                        {
-                                               break;
+                                               num = '';
+                                               isNegative = false;
                                        }
                                }
                        }
+
+                       return isNegative ? "-" + num : num;
                }
 
-               // there are all sorts of variations of zero, such as:
-               // .0    0.   0.0    0000     0000.00000     -0
-               // Here, we simply convert to a 'real' Number and see if
-               // it's resolved to zero. if it does, just return a zero
-               // string and be done with it.
-               if ((num != null) && (str != ''))
+               /**
+                *  Formats a number in exponent notation, into
+                *  a number in decimal notation.
+                *
+                *  @param str String to process in exponent notation.
+                *
+                *  @return Formatted number.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 9
+                *  @playerversion AIR 1.1
+                *  @productversion Flex 3
+                */
+               public function expandExponents(value:String):String
                {
-                       var n:Number = Number(num);
+                       //Break string into component parts
+                       var regExp:RegExp = 
/^([+-])?(\d+).?(\d*)[eE]([-+]?\d+)$/;
+                       var result:Object = regExp.exec(value);
+                       var sign:String = result[1];
+                       var first:String = result[2];
+                       var last:String =  result[3];
+                       var exp:int =  int(result[4]);
+
+                       //if we didn't get a good exponent to begin with, 
return what we can figure out
+                       if (!exp)
+                       {
+                               return (sign ? sign : "") + (first ? first : 
"0") + (last ? "." + last : "");
+                       }
 
-                       if (n == 0)
-                               return '0';
-               }
+                       var r:String = first + last;
 
-               // if the last digit is the dot, whack it
-               if (num)
-               {
-                       if (num.charAt(num.length-1) == '.')
+                       var decimal:Boolean = exp < 0;
+
+                       if (decimal)
                        {
-                               // we have something like 33.
-                               if (num.length >= 2)
-                               {
-                                       num = num.substring(0, num.length-1);
-                               }
-                               // we have merely .
-                               else if (num.length == 1)
-                               {
-                                       num = '';
-                                       isNegative = false;
-                               }
+                               var o:Number = -1 * (first.length + exp) + 1;
+                               return (sign ? sign : "") + "0." + new 
Array(o).join("0") + r;
+                       }
+                       else
+                       {
+                               var i:Number = exp + first.length;
+                               if (i >= r.length)
+                                       return (sign ? sign : "") + r + new 
Array(i - r.length + 1).join("0");
+                               else
+                                       return (sign ? sign : "") + 
r.substr(0,i) + "." + r.substr(i);
                        }
                }
-
-               return isNegative ? "-" + num : num;
        }
-       
-    /**
-     *  Formats a number in exponent notation, into 
-     *  a number in decimal notation.
-     *
-     *  @param str String to process in exponent notation.
-     *
-     *  @return Formatted number.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Flex 3
-     */    
-    public function expandExponents(value:String):String
-    {
-        //Break string into component parts
-        var regExp:RegExp = /^([+-])?(\d+).?(\d*)[eE]([-+]?\d+)$/;
-        var result:Object = regExp.exec(value);
-        var sign:String = result[1];
-        var first:String = result[2];
-        var last:String =  result[3];
-        var exp:int =  int(result[4]);
-                
-        //if we didn't get a good exponent to begin with, return what we can 
figure out
-        if (!exp)
-        {
-            return (sign ? sign : "") + (first ? first : "0") + (last ? "." + 
last : "");
-        }
-                
-        var r:String = first + last;
-                
-        var decimal:Boolean = exp < 0;
-                
-        if (decimal)
-        {   
-            var o:Number = -1 * (first.length + exp) + 1;
-            return (sign ? sign : "") + "0." + new Array(o).join("0") + r;
-        }
-        else
-        {
-            var i:Number = exp + first.length;
-            if (i >= r.length)
-                return (sign ? sign : "") + r + new Array(i - r.length + 
1).join("0");
-            else
-                return (sign ? sign : "") + r.substr(0,i) + "." + r.substr(i); 
-        }
-    }
-}
 
 }
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberFormatter.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberFormatter.as
index 1c879af..91fd4be 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberFormatter.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/formatters/NumberFormatter.as
@@ -20,625 +20,624 @@
 package mx.formatters
 {
 
-import mx.managers.ISystemManager;
-//import mx.managers.SystemManager;
-
-//[ResourceBundle("formatters")]
-//[ResourceBundle("SharedResources")]
-
-[Alternative(replacement="spark.formatters.NumberFormatter", since="4.5")]
-/**
- *  The NumberFormatter class formats a valid number
- *  by adjusting the decimal rounding and precision,
- *  the thousands separator, and the negative sign.
- *
- *  <p>If you use both the <code>rounding</code> and <code>precision</code>
- *  properties, rounding is applied first, and then you set the decimal length
- *  by using the specified <code>precision</code> value.
- *  This lets you round a number and still have a trailing decimal;
- *  for example, 303.99 = 304.00.</p>
- *
- *  <p>If an error occurs, an empty String is returned and a String
- *  describing  the error is saved to the <code>error</code> property.
- *  The <code>error</code>  property can have one of the following values:</p>
- *
- *  <ul>
- *    <li><code>"Invalid value"</code> means an invalid numeric value is 
passed to 
- *    the <code>format()</code> method. The value should be a valid number in 
the 
- *    form of a Number or a String.</li>
- *    <li><code>"Invalid format"</code> means one of the parameters
- *    contain an unusable setting.</li>
- *  </ul>
- *  
- *  @mxml
- *  
- *  <p>The <code>&lt;mx:NumberFormatter&gt;</code> tag
- *  inherits all of the tag attributes of its superclass,
- *  and adds the following tag attributes:</p>
- *  
- *  <pre>
- *  &lt;mx:NumberFormatter
- *    decimalSeparatorFrom="."
- *    decimalSeparatorTo="."
- *    precision="-1"
- *    rounding="none|up|down|nearest"
- *    thousandsSeparatorFrom=","
- *    thousandsSeparatorTo=","
- *    useNegativeSign="true|false"
- *    useThousandsSeparator="true|false"/>  
- *  </pre>
- *  
- *  @includeExample examples/NumberFormatterExample.mxml
- *  
- *  @see mx.formatters.NumberBase
- *  @see mx.formatters.NumberBaseRoundType
- *  
- *  @langversion 3.0
- *  @playerversion Flash 9
- *  @playerversion AIR 1.1
- *  @productversion Royale 0.9.3
- */
-public class NumberFormatter //extends Formatter
-{
-   // include "../core/Version.as";
-    
-    
//--------------------------------------------------------------------------
-    //
-    //  Constructor
-    //
-    
//--------------------------------------------------------------------------
+    import mx.managers.ISystemManager;
+    //import mx.managers.SystemManager;
 
-    /**
-     *  Constructor.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function NumberFormatter()
-    {
-        super();
-    }
-
-    
//--------------------------------------------------------------------------
-    //
-    //  Properties
-    //
-    
//--------------------------------------------------------------------------
-
-    //----------------------------------
-    //  decimalSeparatorFrom
-    //----------------------------------
+    //[ResourceBundle("formatters")]
+    //[ResourceBundle("SharedResources")]
 
+    [Alternative(replacement="spark.formatters.NumberFormatter", since="4.5")]
     /**
-     *  @private
-     *  Storage for the decimalSeparatorFrom property.
-     */
-    private var _decimalSeparatorFrom:String;
-    
-    /**
-     *  @private
-     */
-    //private var decimalSeparatorFromOverride:String;
-    
-    [Inspectable(category="General", defaultValue="null")]
-
-    /**
-     *  Decimal separator character to use
-     *  when parsing an input String.
+     *  The NumberFormatter class formats a valid number
+     *  by adjusting the decimal rounding and precision,
+     *  the thousands separator, and the negative sign.
      *
-     *  <p>When setting this property, ensure that the value of the 
-     *  <code>thousandsSeparatorFrom</code> property does not equal this 
property. 
-     *  Otherwise, an error occurs when formatting the value.</p>
+     *  <p>If you use both the <code>rounding</code> and <code>precision</code>
+     *  properties, rounding is applied first, and then you set the decimal 
length
+     *  by using the specified <code>precision</code> value.
+     *  This lets you round a number and still have a trailing decimal;
+     *  for example, 303.99 = 304.00.</p>
      *
-     *  @default "."
+     *  <p>If an error occurs, an empty String is returned and a String
+     *  describing  the error is saved to the <code>error</code> property.
+     *  The <code>error</code>  property can have one of the following 
values:</p>
      *
-     *  @see #format()
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get decimalSeparatorFrom():String
-    {
-        return _decimalSeparatorFrom;
-    }
-
-    /**
-     *  @private
-     */
-    public function set decimalSeparatorFrom(value:String):void
-    {
-        //decimalSeparatorFromOverride = value;
-
-        _decimalSeparatorFrom = value != null ?
-                                value : value 
-                               /* resourceManager.getString(
-                                    "SharedResources", "decimalSeparatorFrom") 
*/;
-    }
-
-    //----------------------------------
-    //  decimalSeparatorTo
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the decimalSeparatorTo property.
-     */
-    private var _decimalSeparatorTo:String;
-    
-    /**
-     *  @private
-     */
-    //private var decimalSeparatorToOverride:String;
-    
-    [Inspectable(category="General", defaultValue="null")]
-
-    /**
-     *  Decimal separator character to use
-     *  when outputting formatted decimal numbers.
+     *  <ul>
+     *    <li><code>"Invalid value"</code> means an invalid numeric value is 
passed to
+     *    the <code>format()</code> method. The value should be a valid number 
in the
+     *    form of a Number or a String.</li>
+     *    <li><code>"Invalid format"</code> means one of the parameters
+     *    contain an unusable setting.</li>
+     *  </ul>
+     *
+     *  @mxml
      *
-     *  <p>When setting this property, ensure that the value of the  
-     *  <code>thousandsSeparatorTo</code> property does not equal this 
property. 
-     *  Otherwise, an error occurs when formatting the value.</p>
+     *  <p>The <code>&lt;mx:NumberFormatter&gt;</code> tag
+     *  inherits all of the tag attributes of its superclass,
+     *  and adds the following tag attributes:</p>
      *
-     *  @default "."
+     *  <pre>
+     *  &lt;mx:NumberFormatter
+     *    decimalSeparatorFrom="."
+     *    decimalSeparatorTo="."
+     *    precision="-1"
+     *    rounding="none|up|down|nearest"
+     *    thousandsSeparatorFrom=","
+     *    thousandsSeparatorTo=","
+     *    useNegativeSign="true|false"
+     *    useThousandsSeparator="true|false"/>
+     *  </pre>
+     *
+     *  @includeExample examples/NumberFormatterExample.mxml
+     *
+     *  @see mx.formatters.NumberBase
+     *  @see mx.formatters.NumberBaseRoundType
      *
-     *  @see #format()
-     *  
      *  @langversion 3.0
      *  @playerversion Flash 9
      *  @playerversion AIR 1.1
      *  @productversion Royale 0.9.3
      */
-    public function get decimalSeparatorTo():String
+    public class NumberFormatter extends Formatter
     {
-        return _decimalSeparatorTo;
-    }
+       // include "../core/Version.as";
+
+        
//--------------------------------------------------------------------------
+        //
+        //  Constructor
+        //
+        
//--------------------------------------------------------------------------
+
+        /**
+         *  Constructor.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function NumberFormatter()
+        {
+            super();
+        }
 
-    /**
-     *  @private
-     */
-    public function set decimalSeparatorTo(value:String):void
-    {
-        //decimalSeparatorToOverride = value;
+        
//--------------------------------------------------------------------------
+        //
+        //  Properties
+        //
+        
//--------------------------------------------------------------------------
+
+        //----------------------------------
+        //  decimalSeparatorFrom
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the decimalSeparatorFrom property.
+         */
+        private var _decimalSeparatorFrom:String = ".";
+
+        /**
+         *  @private
+         */
+        //private var decimalSeparatorFromOverride:String;
+
+        [Inspectable(category="General", defaultValue=".")]
+
+        /**
+         *  Decimal separator character to use
+         *  when parsing an input String.
+         *
+         *  <p>When setting this property, ensure that the value of the
+         *  <code>thousandsSeparatorFrom</code> property does not equal this 
property.
+         *  Otherwise, an error occurs when formatting the value.</p>
+         *
+         *  @default "."
+         *
+         *  @see #format()
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get decimalSeparatorFrom():String
+        {
+            return _decimalSeparatorFrom;
+        }
 
-        _decimalSeparatorTo = value != null ?
-                              value : value  
-                             /* resourceManager.getString(
-                                "SharedResources", "decimalSeparatorTo") */ ; 
-    }
+        /**
+         *  @private
+         */
+        public function set decimalSeparatorFrom(value:String):void
+        {
+            //decimalSeparatorFromOverride = value;
 
-    //----------------------------------
-    //  precision
-    //----------------------------------
+            _decimalSeparatorFrom = value != null ?
+                                    value : value
+                                   /* resourceManager.getString(
+                                        "SharedResources", 
"decimalSeparatorFrom") */;
+        }
 
-    /**
-     *  @private
-     *  Storage for the precision property.
-     */
-    private var _precision:Object;
-    
-    /**
-     *  @private
-     */
-    //private var precisionOverride:Object;
-    
-    [Inspectable(category="General", defaultValue="null")]
+        //----------------------------------
+        //  decimalSeparatorTo
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the decimalSeparatorTo property.
+         */
+        private var _decimalSeparatorTo:String = ".";
+
+        /**
+         *  @private
+         */
+        //private var decimalSeparatorToOverride:String;
+
+        [Inspectable(category="General", defaultValue=".")]
+
+        /**
+         *  Decimal separator character to use
+         *  when outputting formatted decimal numbers.
+         *
+         *  <p>When setting this property, ensure that the value of the
+         *  <code>thousandsSeparatorTo</code> property does not equal this 
property.
+         *  Otherwise, an error occurs when formatting the value.</p>
+         *
+         *  @default "."
+         *
+         *  @see #format()
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get decimalSeparatorTo():String
+        {
+            return _decimalSeparatorTo;
+        }
 
-    /**
-     *  Number of decimal places to include in the output String.
-     *  You can disable precision by setting it to <code>-1</code>.
-     *  A value of <code>-1</code> means do not change the precision. For 
example, 
-     *  if the input value is 1.453 and <code>rounding</code> 
-     *  is set to <code>NumberBaseRoundType.NONE</code>, return a value of 
1.453.
-     *  If <code>precision</code> is <code>-1</code> and you have set some 
form of 
-     *  rounding, return a value based on that rounding type.
-     *
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get precision():Object
-    {
-        return _precision;
-    }
+        /**
+         *  @private
+         */
+        public function set decimalSeparatorTo(value:String):void
+        {
+            //decimalSeparatorToOverride = value;
 
-    /**
-     *  @private
-     */
-    public function set precision(value:Object):void
-    {
-        //precisionOverride = value;
+            _decimalSeparatorTo = value != null ?
+                                  value : value
+                                 /* resourceManager.getString(
+                                    "SharedResources", "decimalSeparatorTo") 
*/ ;
+        }
 
-        _precision = value != null ?
-                     int(value) : int(value)
-                    /* resourceManager.getInt(
-                         "formatters", "numberFormatterPrecision") */ ;
-    }
+        //----------------------------------
+        //  precision
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the precision property.
+         */
+        private var _precision:Object = -1;
+
+        /**
+         *  @private
+         */
+        //private var precisionOverride:Object;
+
+        [Inspectable(category="General", defaultValue="-1")]
+
+        /**
+         *  Number of decimal places to include in the output String.
+         *  You can disable precision by setting it to <code>-1</code>.
+         *  A value of <code>-1</code> means do not change the precision. For 
example,
+         *  if the input value is 1.453 and <code>rounding</code>
+         *  is set to <code>NumberBaseRoundType.NONE</code>, return a value of 
1.453.
+         *  If <code>precision</code> is <code>-1</code> and you have set some 
form of
+         *  rounding, return a value based on that rounding type.
+         *
+         *  @default -1
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get precision():Object
+        {
+            return _precision;
+        }
 
-    //----------------------------------
-    //  rounding
-    //----------------------------------
+        /**
+         *  @private
+         */
+        public function set precision(value:Object):void
+        {
+            //precisionOverride = value;
 
-    /**
-     *  @private
-     *  Storage for the rounding property.
-     */
-    private var _rounding:String;
-    
-    /**
-     *  @private
-     */
-    //private var roundingOverride:String;
-    
-    [Inspectable(category="General", enumeration="none,up,down,nearest", 
defaultValue="null")]
-        // !!@ Should enumeration include null?
+            _precision = value != null ?
+                         int(value) : int(value)
+                        /* resourceManager.getInt(
+                             "formatters", "numberFormatterPrecision") */ ;
+        }
 
-    /**
-     *  Specifies how to round the number.
-     *
-     *  <p>In ActionScript, you can use the following constants to set this 
property: 
-     *  <code>NumberBaseRoundType.NONE</code>, 
<code>NumberBaseRoundType.UP</code>,
-     *  <code>NumberBaseRoundType.DOWN</code>, or 
<code>NumberBaseRoundType.NEAREST</code>.
-     *  Valid MXML values are "down", "nearest", "up", and "none".</p>
-     *
-     *  @default NumberBaseRoundType.NONE
-     *
-     *  @see mx.formatters.NumberBaseRoundType
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get rounding():String
-    {
-        return _rounding;
-    }
+        //----------------------------------
+        //  rounding
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the rounding property.
+         */
+        private var _rounding:String = "none";
+
+        /**
+         *  @private
+         */
+        //private var roundingOverride:String;
+
+        [Inspectable(category="General", enumeration="none,up,down,nearest", 
defaultValue="none")]
+            // !!@ Should enumeration include null?
+
+        /**
+         *  Specifies how to round the number.
+         *
+         *  <p>In ActionScript, you can use the following constants to set 
this property:
+         *  <code>NumberBaseRoundType.NONE</code>, 
<code>NumberBaseRoundType.UP</code>,
+         *  <code>NumberBaseRoundType.DOWN</code>, or 
<code>NumberBaseRoundType.NEAREST</code>.
+         *  Valid MXML values are "down", "nearest", "up", and "none".</p>
+         *
+         *  @default NumberBaseRoundType.NONE
+         *
+         *  @see mx.formatters.NumberBaseRoundType
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get rounding():String
+        {
+            return _rounding;
+        }
 
-    /**
-     *  @private
-     */
-    public function set rounding(value:String):void
-    {
-        //roundingOverride = value;
+        /**
+         *  @private
+         */
+        public function set rounding(value:String):void
+        {
+            //roundingOverride = value;
 
-        _rounding = value != null ?
-                    value : value
-                   /* resourceManager.getString(
-                        "formatters", "rounding") */ ;
-    }
+            _rounding = value != null ?
+                        value : value
+                       /* resourceManager.getString(
+                            "formatters", "rounding") */ ;
+        }
 
-    //----------------------------------
-    //  thousandsSeparatorFrom
-    //----------------------------------
+        //----------------------------------
+        //  thousandsSeparatorFrom
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the thousandsSeparatorFrom property.
+         */
+        private var _thousandsSeparatorFrom:String = ",";
+
+        /**
+         *  @private
+         */
+        //private var thousandsSeparatorFromOverride:String;
+
+        [Inspectable(category="General", defaultValue=",")]
+
+        /**
+         *  Character to use as the thousands separator
+         *  in the input String.
+         *
+         *  <p>When setting this property, ensure that the value of the
+         *  <code>decimalSeparatorFrom</code> property does not equal this 
property.
+         *  Otherwise, an error occurs when formatting the value.</p>
+         *
+         *  @default ","
+         *
+         *  @see #format()
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get thousandsSeparatorFrom():String
+        {
+            return _thousandsSeparatorFrom;
+        }
 
-    /**
-     *  @private
-     *  Storage for the thousandsSeparatorFrom property.
-     */
-    private var _thousandsSeparatorFrom:String;
-    
-    /**
-     *  @private
-     */
-    //private var thousandsSeparatorFromOverride:String;
-    
-    [Inspectable(category="General", defaultValue="null")]
+        /**
+         *  @private
+         */
+        public function set thousandsSeparatorFrom(value:String):void
+        {
+            //thousandsSeparatorFromOverride = value;
 
-    /**
-     *  Character to use as the thousands separator
-     *  in the input String.
-     *
-     *  <p>When setting this property, ensure that the value of the
-     *  <code>decimalSeparatorFrom</code> property does not equal this 
property. 
-     *  Otherwise, an error occurs when formatting the value.</p>
-     *
-     *  @default ","
-     *
-     *  @see #format()
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get thousandsSeparatorFrom():String
-    {
-        return _thousandsSeparatorFrom;
-    }
+            _thousandsSeparatorFrom = value != null ?
+                                      value : value
+                                     /* resourceManager.getString(
+                                          "SharedResources",
+                                          "thousandsSeparatorFrom"); */
+        }
 
-    /**
-     *  @private
-     */
-    public function set thousandsSeparatorFrom(value:String):void
-    {
-        //thousandsSeparatorFromOverride = value;
+        //----------------------------------
+        //  thousandsSeparatorTo
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the thousandsSeparatorTo property.
+         */
+        private var _thousandsSeparatorTo:String = ",";
+
+        /**
+         *  @private
+         */
+        //private var thousandsSeparatorToOverride:String;
+
+        [Inspectable(category="General", defaultValue=",")]
+
+        /**
+         *  Character to use as the thousands separator
+         *  in the output String.
+         *
+         *  <p>When setting this property, ensure that the value of the
+         *  <code>decimalSeparatorTo</code> property does not equal this 
property.
+         *  Otherwise, an error occurs when formatting the value.</p>
+         *
+         *  @default ","
+         *
+         *  @see #format()
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get thousandsSeparatorTo():String
+        {
+            return _thousandsSeparatorTo;
+        }
 
-        _thousandsSeparatorFrom = value != null ?
-                                  value : value
-                                 /* resourceManager.getString(
-                                      "SharedResources",
-                                      "thousandsSeparatorFrom"); */
-    }
-    
-    //----------------------------------
-    //  thousandsSeparatorTo
-    //----------------------------------
+        /**
+         *  @private
+         */
+        public function set thousandsSeparatorTo(value:String):void
+        {
+            //thousandsSeparatorToOverride = value;
 
-    /**
-     *  @private
-     *  Storage for the thousandsSeparatorTo property.
-     */
-    private var _thousandsSeparatorTo:String;
-    
-    /**
-     *  @private
-     */
-    //private var thousandsSeparatorToOverride:String;
-    
-    [Inspectable(category="General", defaultValue="null")]
+            _thousandsSeparatorTo = value != null ?
+                                    value : value
+                                  /*  resourceManager.getString(
+                                        "SharedResources",
+                                        "thousandsSeparatorTo") */ ;
+        }
 
-    /**
-     *  Character to use as the thousands separator
-     *  in the output String.
-     *
-     *  <p>When setting this property, ensure that the value of the  
-     *  <code>decimalSeparatorTo</code> property does not equal this property. 
-     *  Otherwise, an error occurs when formatting the value.</p>
-     *
-     *  @default ","
-     *
-     *  @see #format()
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get thousandsSeparatorTo():String
-    {
-        return _thousandsSeparatorTo;
-    }
+        //----------------------------------
+        //  useNegativeSign
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the useNegativeSign property.
+         */
+        private var _useNegativeSign:Object = true;
+
+        /**
+         *  @private
+         */
+        //private var useNegativeSignOverride:Object;
+
+        [Inspectable(category="General", defaultValue="true")]
+
+        /**
+         *  If <code>true</code>, format a negative number
+         *  by preceding it with a minus "-" sign.
+         *  If <code>false</code>, format the number
+         *  surrounded by parentheses, for example (400).
+         *
+         *  @default true
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get useNegativeSign():Object
+        {
+            return _useNegativeSign;
+        }
 
-    /**
-     *  @private
-     */
-    public function set thousandsSeparatorTo(value:String):void
-    {
-        //thousandsSeparatorToOverride = value;
+        /**
+         *  @private
+         */
+        public function set useNegativeSign(value:Object):void
+        {
+            //useNegativeSignOverride = value;
 
-        _thousandsSeparatorTo = value != null ?
-                                value : value
-                              /*  resourceManager.getString(
-                                    "SharedResources",
-                                    "thousandsSeparatorTo") */ ; 
-    }
+            _useNegativeSign = value != null ?
+                               Boolean(value) : Boolean(value)
+                            /*   resourceManager.getBoolean(
+                                   "formatters", "useNegativeSignInNumber") */ 
;
+        }
 
-    //----------------------------------
-    //  useNegativeSign
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the useNegativeSign property.
-     */
-    private var _useNegativeSign:Object;
-    
-    /**
-     *  @private
-     */
-    //private var useNegativeSignOverride:Object;
-    
-    [Inspectable(category="General", defaultValue="null")]
+        //----------------------------------
+        //  useThousandsSeparator
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the useThousandsSeparator property.
+         */
+        private var _useThousandsSeparator:Object = true;
+
+        /**
+         *  @private
+         */
+        //private var useThousandsSeparatorOverride:Object;
+
+        [Inspectable(category="General", defaultValue="true")]
+
+        /**
+         *  If <code>true</code>, split the number into thousands increments
+         *  by using a separator character.
+         *
+         *  @default true
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        public function get useThousandsSeparator():Object
+        {
+            return _useThousandsSeparator;
+        }
 
-    /**
-     *  If <code>true</code>, format a negative number 
-     *  by preceding it with a minus "-" sign.
-     *  If <code>false</code>, format the number
-     *  surrounded by parentheses, for example (400).
-     *
-     *  @default true
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get useNegativeSign():Object
-    {
-        return _useNegativeSign;
-    }
+        /**
+         *  @private
+         */
+        public function set useThousandsSeparator(value:Object):void
+        {
+            //useThousandsSeparatorOverride = value;
 
-    /**
-     *  @private
-     */
-    public function set useNegativeSign(value:Object):void
-    {
-        //useNegativeSignOverride = value;
+            _useThousandsSeparator = value != null ?
+                                     Boolean(value) : Boolean(value)
+                                 /*     resourceManager.getBoolean(
+                                         "formatters", 
"useThousandsSeparator") */ ;
+        }
 
-        _useNegativeSign = value != null ?
-                           Boolean(value) : Boolean(value)
-                        /*   resourceManager.getBoolean(
-                               "formatters", "useNegativeSignInNumber") */ ;
-    }
+        
//--------------------------------------------------------------------------
+        //
+        //  Overridden methods
+        //
+        
//--------------------------------------------------------------------------
+        /**
+         *  Formats the number as a String.
+         *  If <code>value</code> cannot be formatted, return an empty String
+         *  and write a description of the error to the <code>error</code> 
property.
+         *
+         *  @param value Value to format.
+         *
+         *  @return Formatted String. Empty if an error occurs.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.9.3
+         */
+        override public function format(value:Object):String
+        {
+            // Reset any previous errors.
+            //if (error)
+            //    error = null;
 
-    //----------------------------------
-    //  useThousandsSeparator
-    //----------------------------------
+            if (useThousandsSeparator &&
+                ((decimalSeparatorFrom == thousandsSeparatorFrom) ||
+                 (decimalSeparatorTo == thousandsSeparatorTo)))
+            {
+                //error = defaultInvalidFormatError;
+                return "";
+            }
 
-    /**
-     *  @private
-     *  Storage for the useThousandsSeparator property.
-     */
-    private var _useThousandsSeparator:Object;
-    
-    /**
-     *  @private
-     */
-    //private var useThousandsSeparatorOverride:Object;
-    
-    [Inspectable(category="General", defaultValue="null")]
+            if (decimalSeparatorTo == "" || !isNaN(Number(decimalSeparatorTo)))
+            {
+                //error = defaultInvalidFormatError;
+                return "";
+            }
 
-    /**
-     *  If <code>true</code>, split the number into thousands increments
-     *  by using a separator character.
-     *
-     *  @default true
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-    public function get useThousandsSeparator():Object
-    {
-        return _useThousandsSeparator;
-    }
+            var dataFormatter:NumberBase = new NumberBase(decimalSeparatorFrom,
+                                                          
thousandsSeparatorFrom,
+                                                          decimalSeparatorTo,
+                                                          
thousandsSeparatorTo);
 
-    /**
-     *  @private
-     */
-    public function set useThousandsSeparator(value:Object):void
-    {
-        //useThousandsSeparatorOverride = value;
+            // -- value --
 
-        _useThousandsSeparator = value != null ?
-                                 Boolean(value) : Boolean(value)
-                             /*     resourceManager.getBoolean(
-                                     "formatters", "useThousandsSeparator") */ 
;
-    }
+            if (value is String)
+                value = dataFormatter.parseNumberString(String(value));
 
-    
//--------------------------------------------------------------------------
-    //
-    //  Overridden methods
-    //
-    
//--------------------------------------------------------------------------
-    /**
-     *  Formats the number as a String.
-     *  If <code>value</code> cannot be formatted, return an empty String 
-     *  and write a description of the error to the <code>error</code> 
property.
-     *
-     *  @param value Value to format.
-     *
-     *  @return Formatted String. Empty if an error occurs.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.3
-     */
-        
-    /*override*/ public function format(value:Object):String
-    {
-        // Reset any previous errors.
-        //if (error)
-        //    error = null;
+            if (value === null || isNaN(Number(value)))
+            {
+                //error = defaultInvalidValueError;
+                return "";
+            }
 
-        if (useThousandsSeparator &&
-            ((decimalSeparatorFrom == thousandsSeparatorFrom) ||
-             (decimalSeparatorTo == thousandsSeparatorTo)))
-        {
-            //error = defaultInvalidFormatError;
-            return "";
-        }
+            // -- format --
 
-        if (decimalSeparatorTo == "" || !isNaN(Number(decimalSeparatorTo)))
-        {
-            //error = defaultInvalidFormatError;
-            return "";
-        }
+            var isNegative:Boolean = (Number(value) < 0);
 
-       /* var dataFormatter:NumberBase = new NumberBase(decimalSeparatorFrom,
-                                                      thousandsSeparatorFrom,
-                                                      decimalSeparatorTo,
-                                                      thousandsSeparatorTo); */
-          
-        // -- value --
+            var numStr:String = value.toString();
 
-       /* if (value is String)
-            value = dataFormatter.parseNumberString(String(value)); */
+            numStr = numStr.toLowerCase();
+            var e:int = numStr.indexOf("e");
+            if (e != -1)  //deal with exponents
+                numStr = dataFormatter.expandExponents(numStr);
 
-        if (value === null || isNaN(Number(value)))
-        {
-            //error = defaultInvalidValueError;
-            return "";
-        } 
+            var numArrTemp:Array = numStr.split(".");
+            var numFraction:int = numArrTemp[1] ? String(numArrTemp[1]).length 
: 0;
 
-        // -- format --
+            if (precision < numFraction)
+            {
+                if (rounding != NumberBaseRoundType.NONE)
+                {
+                    numStr = dataFormatter.formatRoundingWithPrecision(
+                        numStr, rounding, int(precision));
+                }
+            }
 
-        var isNegative:Boolean = (Number(value) < 0);
+            var numValue:Number = Number(numStr);
+            if (Math.abs(numValue) >= 1)
+            {
+                numArrTemp = numStr.split(".");
+                var front:String = useThousandsSeparator ?
+                                   
dataFormatter.formatThousands(String(numArrTemp[0])) :
+                                   String(numArrTemp[0]);
+                if (numArrTemp[1] != null && numArrTemp[1] != "")
+                    numStr = front + decimalSeparatorTo + numArrTemp[1];
+                else
+                    numStr = front;
+            }
+            else if (Math.abs(numValue) > 0)
+            {
+                // Check if the string is in scientific notation
+                numStr = numStr.toLowerCase();
+                if (numStr.indexOf("e") != -1)
+                {
+                    var temp:Number = Math.abs(numValue) + 1;
+                    numStr = temp.toString();
+                }
+                numStr = decimalSeparatorTo +
+                         numStr.substring(numStr.indexOf(".") + 1);
+            }
 
-        var numStr:String = value.toString();
-        
-               numStr = numStr.toLowerCase();
-        var e:int = numStr.indexOf("e");
-        /*if (e != -1)  //deal with exponents
-            numStr = dataFormatter.expandExponents(numStr); */
-            
-        var numArrTemp:Array = numStr.split(".");
-        var numFraction:int = numArrTemp[1] ? String(numArrTemp[1]).length : 0;
+           // numStr = dataFormatter.formatPrecision(numStr, int(precision));
 
-        /*if (precision < numFraction)
-        {
-            if (rounding != NumberBaseRoundType.NONE)
+            // If our value is 0, then don't show -0
+            if (Number(numStr) == 0)
             {
-                numStr = dataFormatter.formatRoundingWithPrecision(
-                    numStr, rounding, int(precision));
-            } 
-        }*/
+                isNegative = false;
+            }
 
-        var numValue:Number = Number(numStr);
-        if (Math.abs(numValue) >= 1)
-        {
-            numArrTemp = numStr.split(".");
-           /* var front:String = useThousandsSeparator ?
-                               
dataFormatter.formatThousands(String(numArrTemp[0])) :
-                               String(numArrTemp[0]); 
-            if (numArrTemp[1] != null && numArrTemp[1] != "")
-                numStr = front + decimalSeparatorTo + numArrTemp[1];
-            else
-                numStr = front;*/
-        }
-        else if (Math.abs(numValue) > 0)
-        {
-            // Check if the string is in scientific notation
-                       numStr = numStr.toLowerCase();
-                       if (numStr.indexOf("e") != -1)
+            if (isNegative)
+                numStr = dataFormatter.formatNegative(numStr, useNegativeSign);
+
+            if (!dataFormatter.isValid)
             {
-                var temp:Number = Math.abs(numValue) + 1;
-                numStr = temp.toString();
+                error = defaultInvalidFormatError;
+                return "";
             }
-            numStr = decimalSeparatorTo +
-                     numStr.substring(numStr.indexOf(".") + 1);
-        }
-        
-       // numStr = dataFormatter.formatPrecision(numStr, int(precision));
 
-        // If our value is 0, then don't show -0
-        if (Number(numStr) == 0)
-        {
-            isNegative = false; 
+            return numStr;
         }
 
-       /* if (isNegative)
-            numStr = dataFormatter.formatNegative(numStr, useNegativeSign); */
-
-       /* if (!dataFormatter.isValid)
-        {
-            error = defaultInvalidFormatError;
-            return "";
-        }
-               */
-        return numStr;
     }
-        
-}
 
 }

Reply via email to