1 | package {
|
---|
2 | import object_helper;
|
---|
3 |
|
---|
4 | public class NumberFormat
|
---|
5 | {
|
---|
6 | public static var DEFAULT_NUM_DECIMALS:Number = 2;
|
---|
7 |
|
---|
8 | public var numDecimals:Number = DEFAULT_NUM_DECIMALS;
|
---|
9 | public var isFixedNumDecimalsForced:Boolean = false;
|
---|
10 | public var isDecimalSeparatorComma:Boolean = false;
|
---|
11 | public var isThousandSeparatorDisabled:Boolean = false;
|
---|
12 |
|
---|
13 | public function NumberFormat( numDecimals:Number, isFixedNumDecimalsForced:Boolean, isDecimalSeparatorComma:Boolean, isThousandSeparatorDisabled:Boolean )
|
---|
14 | {
|
---|
15 | this.numDecimals = Parser.getNumberValue (numDecimals, DEFAULT_NUM_DECIMALS, true, false);
|
---|
16 | this.isFixedNumDecimalsForced = Parser.getBooleanValue(isFixedNumDecimalsForced,false);
|
---|
17 | this.isDecimalSeparatorComma = Parser.getBooleanValue(isDecimalSeparatorComma,false);
|
---|
18 | this.isThousandSeparatorDisabled = Parser.getBooleanValue(isThousandSeparatorDisabled,false);
|
---|
19 | }
|
---|
20 |
|
---|
21 |
|
---|
22 | //singleton
|
---|
23 | // public static function getInstance (lv,c:Number):NumberFormat{
|
---|
24 | // if (c==2){
|
---|
25 | // return NumberFormat.getInstanceY2(lv);
|
---|
26 | // } else {
|
---|
27 | // return NumberFormat.getInstance(lv);
|
---|
28 | // }
|
---|
29 | // }
|
---|
30 |
|
---|
31 | private static var _instance:NumberFormat = null;
|
---|
32 |
|
---|
33 | public static function getInstance( json:Object ):NumberFormat {
|
---|
34 | if (_instance == null) {
|
---|
35 | // if (lv==undefined || lv == null){
|
---|
36 | // lv=_root.lv;
|
---|
37 | // }
|
---|
38 |
|
---|
39 | var o:Object = {
|
---|
40 | num_decimals: 2,
|
---|
41 | is_fixed_num_decimals_forced: 0,
|
---|
42 | is_decimal_separator_comma: 0,
|
---|
43 | is_thousand_separator_disabled: 0
|
---|
44 | };
|
---|
45 |
|
---|
46 | object_helper.merge_2( json, o );
|
---|
47 |
|
---|
48 | _instance = new NumberFormat (
|
---|
49 | o.num_decimals,
|
---|
50 | o.is_fixed_num_decimals_forced==1,
|
---|
51 | o.is_decimal_separator_comma==1,
|
---|
52 | o.is_thousand_separator_disabled==1
|
---|
53 | );
|
---|
54 | // trace ("getInstance NEW!!!!");
|
---|
55 | // trace (_instance.numDecimals);
|
---|
56 | // trace (_instance.isFixedNumDecimalsForced);
|
---|
57 | // trace (_instance.isDecimalSeparatorComma);
|
---|
58 | // trace (_instance.isThousandSeparatorDisabled);
|
---|
59 | } else {
|
---|
60 | //trace ("getInstance found");
|
---|
61 | }
|
---|
62 | return _instance;
|
---|
63 | }
|
---|
64 |
|
---|
65 | private static var _instanceY2:NumberFormat = null;
|
---|
66 |
|
---|
67 | public static function getInstanceY2( json:Object ):NumberFormat{
|
---|
68 | if (_instanceY2 == null) {
|
---|
69 | // if (lv==undefined || lv == null){
|
---|
70 | // lv=_root.lv;
|
---|
71 | // }
|
---|
72 |
|
---|
73 | var o:Object = {
|
---|
74 | num_decimals: 2,
|
---|
75 | is_fixed_num_decimals_forced: 0,
|
---|
76 | is_decimal_separator_comma: 0,
|
---|
77 | is_thousand_separator_disabled: 0
|
---|
78 | };
|
---|
79 |
|
---|
80 | object_helper.merge_2( json, o );
|
---|
81 |
|
---|
82 | _instanceY2 = new NumberFormat (
|
---|
83 | o.num_decimals,
|
---|
84 | o.is_fixed_num_decimals_forced==1,
|
---|
85 | o.is_decimal_separator_comma==1,
|
---|
86 | o.is_thousand_separator_disabled==1
|
---|
87 | );
|
---|
88 |
|
---|
89 | //trace ("getInstanceY2 NEW!!!!");
|
---|
90 | } else {
|
---|
91 | //trace ("getInstanceY2 found");
|
---|
92 | }
|
---|
93 | return _instanceY2;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | }
|
---|