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

help with dynamic text in animate cc

New Here ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

hello how are you, i have this problem in a dynamic text i want numbers to appear from a simple sum, my code is this

Var sum: Number = 1;

var counter: Number;

counter = sum +1; Text.text = "" + counter;

but it doesn't appear in the dynamic text and the instance of the dynamic text is called Text

Views

474

Translate

Translate

Report

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 ,
May 24, 2020 May 24, 2020

Copy link to clipboard

Copied

Hi.

 

It's because you didn't initialize the counter variable.

 

It should be something like:

var counter:Number = 0;

 

Regards,

JC

Votes

Translate

Translate

Report

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
LEGEND ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

LATEST

That would be the solution if he was doing counter++, which he's not.

 

cristianrnumbers, what do you see if you replace the text display code with:

Text.text = "HELLO";

?

 

Also, using "Text" as an instance name is a terrible, no good, very bad idea. "Text" is a property name. Even if it works, it leads to confusing-looking code. Name your textfields descriptively, or at the very least something like "mytext" or "text1" or whatever.

Votes

Translate

Translate

Report

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