Skip to main content
Participant
May 24, 2020
Question

help with dynamic text in animate cc

  • May 24, 2020
  • 1 reply
  • 571 views

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

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    May 24, 2020

    Hi.

     

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

     

    It should be something like:

    var counter:Number = 0;

     

    Regards,

    JC

    Legend
    May 26, 2020

    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.