Skip to main content
Known Participant
July 9, 2010
Answered

Can't make a numeric value appear in a dynamic text window

  • July 9, 2010
  • 1 reply
  • 511 views

I am tying to make a number appear in a dynamic text window. I have a dynamic textfield on the stage with an instance name called count_txt. The code that I am using is shown below. Both tace statements show a value of 100 but nothing appears in the dynamic text window. What am I doing wrong?

var count_txt:Number;

var n:Number;

n = 100;

trace(n);

count_txt = n;

trace(count_txt);

stop();
This topic has been closed for replies.
Correct answer

Text fields have a text property that you use to set the text in the field. And when you want to stick a number in the field you will need to cast it to a String first:

count_txt.text = String(n);

trace(count_txt.text);

1 reply

Correct answer
July 9, 2010

Text fields have a text property that you use to set the text in the field. And when you want to stick a number in the field you will need to cast it to a String first:

count_txt.text = String(n);

trace(count_txt.text);

Known Participant
July 9, 2010

Thanks very much. It is working now. I changed the code as shown below.

var n:Number;
n = 100;
trace(n);
count_txt.text = String(n);
trace(count_txt.text);
stop();