Skip to main content
July 14, 2013
Answered

[object object] dynamic text error :(

  • July 14, 2013
  • 1 reply
  • 565 views

Hey, I was just in the middle of my programming and I wrote this onto some dynamic text:

var wood:Number;

wood = 0;

var water:Number;

water = 0;

var s_water:String;

s_water = toString(water);

var s_wood:String;

s_wood = toString(wood);

statsInstance.text = "wood: " + s_wood + " water: " + s_water;

And then when I run it, the text shows:

wood: [object object] water: [object object]

Please help!

Thanks.

This topic has been closed for replies.
Correct answer kglad

there is a method toString(), it's not used like that.

and, it's not clear what you're trying to do but you'll probably come closer to what you want by casting wood and water as strings:

var wood:Number;

wood = 0;

var water:Number;

water = 0;

var s_water:String;

s_water = String(water);

var s_wood:String;

s_wood = String(wood);

statsInstance.text = "wood: " + s_wood + " water: " + s_water;

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 14, 2013

there is a method toString(), it's not used like that.

and, it's not clear what you're trying to do but you'll probably come closer to what you want by casting wood and water as strings:

var wood:Number;

wood = 0;

var water:Number;

water = 0;

var s_water:String;

s_water = String(water);

var s_wood:String;

s_wood = String(wood);

statsInstance.text = "wood: " + s_wood + " water: " + s_water;

July 14, 2013

Thx! You helped me alot!!!!!!!! XD XD

kglad
Community Expert
Community Expert
July 14, 2013

you're welcome.