Copy link to clipboard
Copied
Copy link to clipboard
Copied
1. use classic text.
2: you can use formatF() below to convert your textfield's text property to the format you want:
function formatF(s:String):String{
var n:Number=Number(s);
n = Math.round(n*100)/100;
var s1:String = n.toString();
var a:Array = s1.split(".");
while(a[1].length<2){
a[1] = a[1]+"0";
}
return "$"+a[0]+"."+a[1];
}
Copy link to clipboard
Copied
1. I actually figured this out - I had to embed the font in every instance and it finally worked.
2. Sorry, I don't understand where I'm supposed to add this function. If you can post an example, that would be great - maybe it's just a matter of me not understanding which parts need to be substituted.
Thanks.
Copy link to clipboard
Copied
copy and paste the code for that function anywhere that executes before calling it. you can call it like:
yourTF.text = formatF(yourTF.text);
Copy link to clipboard
Copied
It keeps giving me this output error: TypeError: Error #1010: A term is undefined and has no properties. at Calc_fla::MainTimeline/formatF()
Copy link to clipboard
Copied
use:
function formatF(s:String):String{
var n:Number=Number(s);
n = Math.round(n*100)/100;
var s1:String = n.toString();
if(s1.indexOf(".")==-1){
return s1+".00";
}
var a:Array = s1.split(".");
while(a[1].length<2){
a[1] = a[1]+"0";
}
return "$"+a[0]+"."+a[1];
}
Copy link to clipboard
Copied
Yay! No more errors!
The decimal point and decimal places work but I don't see commas or the dollar sign. ![]()
Copy link to clipboard
Copied
you'll need to format the commas. here's the dollar sign:
kglad wrote:
use:
function formatF(s:String):String{
var n:Number=Number(s);
n = Math.round(n*100)/100;
var s1:String = n.toString();
if(s1.indexOf(".")==-1){
return "$"+s1+".00";
}
var a:Array = s1.split(".");
while(a[1].length<2){
a[1] = a[1]+"0";
}
return "$"+a[0]+"."+a[1];
}
Copy link to clipboard
Copied
Okay, the dollar sign works now and I figured out the comma! So happy!
But there seems to be a problem, it works great in my local machine but when i upload it to our website, all the formatting drops! No decimal point, no comma, no $.
[as]
function formatF(s:String):String
{
var n:Number=Number(s);
n = Math.round(n*100)/100;
var s1:String = n.toString();
if(s1.indexOf(".")==-1)
var rgx:RegExp = /(\d+)(\d{3})/;
while (rgx.test(s1)) {
s1 = s1.replace(rgx, "$1" + "," + "$2");
}
{
return "$"+s1+".00";
}
var a:Array = s1.split(".");
while(a[1].length<2){
a[1] = a[1]+"0";
}
return "$"+a[0]+"."+a[1];
}
[as]
Copy link to clipboard
Copied
there's nothing in formatF() that would make any difference when executed in an online vs local swf.
on the other hand, there are quite a few things that do change when executed in an online vs local swf.
Copy link to clipboard
Copied
That's what I thought... Anyway, I made different computations and I've narrowed the instance when the uploaded version drops the currency formatting - it only happens when I have an input text that has a decimal point in it. It works great in the local version but not the uploaded version. The uploaded version works fine as long as the numbers I use are whole numbers.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more