开发者

Flash Actionscript 3 passing a number to dynamic text field

开发者 https://www.devze.com 2022-12-16 15:04 出处:网络
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

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

精彩评论

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