开发者

Flash Actionscript 3 passing a number to dynamic text field

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.t开发者_Python百科ext = livesnum;

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


Use toString() function:

lives.text=livesnum.toString()

or use a cast String():

lives.text=String(livesnum);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜