3
votes

On my stage I have a dynamic text field (instance name = lives).

In my actionscript I have created a number variable called livesnum. And then beneath that I'm setting the textfields value to be the livesnum variable but I get the following error:

1067: Implicit coercion of a value of type Number to an unrelated type String.

My actionscript is as follows :

var livesnum:Number = 4; //Amount of lives

lives.text = livesnum;

How would I achieve setting the textfield as the numeric value of the variable?

1

1 Answers

4
votes

Use toString() function:

lives.text=livesnum.toString()

or use a cast String():

lives.text=String(livesnum);