Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[object object] dynamic text error :(

Guest
Jul 14, 2013 Jul 14, 2013

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.

TOPICS
ActionScript
532
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 14, 2013 Jul 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;

Translate
Community Expert ,
Jul 14, 2013 Jul 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 14, 2013 Jul 14, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 14, 2013 Jul 14, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines