Problems with dynamic TextField and decimal Number

Ohlilie

I've made a little program with Flash and Actionscript in which there is a dynamic TextField which should be filled with a decimal Number. The var "number" holds a value which has a lot of decimal places, but only two of these should be shown.

When I trace the Number

trace(number.toFixed(2));

it gives back 20.49 which is exactly the value I want.

But when I'm trying to write that value into my TextField the comma disapears.

txt_Field.text = number.toFixed(2);

In the TextField is written 2049 but the comma is missing. When i try different values as number the output of the TextField has several mistakes like i.e. only one deimal place, a missing character, ...

What am I doing wrong?

3vilguy

I think it's a problem with displaying this value. Few possible options in here:

First of all, can you check what TextField text value actually is:

var testString:String = number.toFixed(2);
trace(testString);
txt_Field.text = testString;
trace(txt_Field.text);

If trace is showing you value with "." then it's display issue. In this case check if TextField in not to small to fit number and decimal (you can turn on debug border), or if you have font embedded.

You can also try to force show string with dots, just to see if TextField is actually showing them at all.

txt_Field.text = "test.TEST.test;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related