how do i make the numbers in the dynamic text box appear to have two decimal places eg currency(Flash MX)

thanx

p.s i am calculaitng a cost on one frame and when button pressed the output is shown on the next frame

thanx

p.s i am calculaitng a cost on one frame and when button pressed the output is shown on the next frame

might be a better place to ask

still look at these links if they help

http://oldlook.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20521418.html

http://oldlook.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20534277.html

This one took a while but I think I have it. I am assuming that you are using actionscript, as this is the only way you can do this.

Here is the Code, with some comments. I called my dynamic Text Box "number". I know it is a bit long, but I tried this various ways, and this is the shortest I could come up with.

count is just a number that I used to test on.

count = 123456789.56;

if (count > 1000)

{

// Get rid of the decimal

decimal = count%1.0;

// Turn everything but the decimal into a string, as this is what you want to add comma's or periods to

output = String(count-decimal);

//Declare a new array

temp_array = new Array();

// This is just used as a holder for the string length from base 0

number_length = output.length - 1;

// Iterate over string, and add comma's where required, at every third character

for (i = 0; i < output.length; i++) {

if (i%3 == 0 && i != 0)

temp_array.push(",");

temp_array.push(output.cha

}

// Pop the items off of the stack and print them to the dynamic string on the screen for the user

while (temp_array.length)

number.text += temp_array.pop();

// Time to add the decimal

output = String(decimal);

// Remember to not add the initial 0 in the decimal. only everything from the decimal point onwards

for (i = 1; i < output.length; i++)

number.text += output.charAt(i);

}

else // If the number is smaller than 1000, use as is

number.text = count;

All Courses

From novice to tech pro — start learning today.

It requires the expert setting up some dynamic and static text fields corresponding to number and temp.

number.text = "";

count = temp.text;

if (count > 1000)

{

decimal = count%1.0;

output = String(count-decimal);

temp_array = new Array();

number_length = output.length - 1;

for (i = 0; i < output.length; i++) {

if (i%3 == 0 && i != 0)

temp_array.push(",");

temp_array.push(output.cha

}

while (temp_array.length)

number.text += temp_array.pop();

output = String(decimal);

for (i = 1; i < output.length; i++)

number.text += output.charAt(i);

}

else

number.text = count;