Function fun (data: INT): String {
VaR STR: String = string (data );
VaR B: String = new string ();
VaR C: String = new string ();
VaR D: String = new string ()
VaR E: String = new string ()
VaR F: String = new string ()
For (var j: Int = Str. length; j> = 0; j --){
E + = Str. charat (j)
}
For (var I: Int = 0; I <E. length; I + = 3 ){
C + = B. Concat ("," + E. substring (I, I + 3 ));
}
If (C. charat (0) = ","){
D = C. substring (1, C. length)
} Else {
D = C
}
For (var n: Int = D. length; n> = 0; n --){
F + = D. charat (N)
}
Return F;
}
Trace (fun (121312324245 ));
This is the principle and needs to be optimized.
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Simple example to demonstrate the currencyformatter. -->
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Events. validationresultevent;
Private var vresult: validationresultevent;
// Event handler to validate and format input.
Private function Format (): void {
Vresult = numval. Validate ();
If (vresult. type = validationresultevent. Valid ){
VaR temp: Number = Number (priceus. Text );
Formattedusprice. Text = usdformatter. Format (temp );
}
Else {
Formattedusprice. Text = "";
}
}
]>
</MX: SCRIPT>
<Mx: currencyformatter id = "usdformatter" precision = "2"
Currencysymbol = "" decimalseparatorfrom = "."
Decimalseparatorto = "." usenegativesign = "true"
Usethousandsseparator = "true" alignsymbol = "Left"/>
<Mx: numbervalidator id = "numval" Source = "{priceus}" property = "text"
Allownegative = "true" Domain = "real"/>
<Mx: panel title = "currencyformatter example" width = "75%" Height = "75%"
Paddingtop = "10" paddingleft = "10" paddingright = "10" paddingbottom = "10">
<Mx: Form>
<Mx: formitem label = "enter U. S. dollar amount:">
<Mx: textinput id = "priceus" text = "" width = "50%"/>
</MX: formitem>
<Mx: formitem label = "formatted amount:">
<Mx: textinput id = "formattedusprice" text = "" width = "50%" editable = "false"/>
</MX: formitem>
<Mx: formitem>
<Mx: button label = "Validate and format" Click = "format ();"/>
</MX: formitem>
</MX: Form>
</MX: Panel>
</MX: Application>