Skip to main content
Participating Frequently
April 9, 2018
Answered

Dynamic text update problem

  • April 9, 2018
  • 6 replies
  • 2297 views

I am making a menu, with lots of submenus using HTML5 Canvas in Animate CC.

I am running into a weird problem.

I have simplified the problem as much as I could into this fla:

Broken Example.fla - Google Drive

What you'll see in that fla is this:

  • A single frame in the JS layer that has code
  • A second frame with a single, dynamic text box that has the instance name txtBoxOne
  • A third frame with 2 dynamic text boxes, with instance names txtBoxTwo and txtBoxThree

The javascript starts running a function in the background that updates these text boxes, if they exist as properties of the exportRoot object.

What I expect to see when I run this in a browser is this:

  • It skips to frame 3
  • The text in txtBoxTwo changes from "2" to "txtBoxTwo" within a few seconds
  • The text in txtBoxThree changes from "3" to "txtBoxThree" within a few seconds

What I see is this:

  • It skips to frame 3
  • The text in txtBoxTwo changes from "2" to "txtBoxTwo" within a few seconds
  • The text in txtBoxThree changes from "3" to "txtBoxOne" within a few seconds

If I remove the second frame however, everything works as expected.

Why does this happen? What am I doing wrong?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer JoãoCésar17023019

    Hi.

    This is something I've also been facing lately and I think it is a limitation of the CreateJS suite in Animate CC. I hope someone else can clarify this for us.

    Because what I can tell is that text fields don't get registered as children properly - or don't get registered at all - if they aren't in the first frame.

    In your case, it seems that only the first text field (lower z index) of the third frame gets registered.

    Run a test logging the exportRoot or the "this" property. You'll see that only the "txtBoxOne" and the "txtBoxTwo" are registered as children. But, if you send the "txtBoxThree" to the bottom of the stack - index 0 - you'll see it will be the one being registered.

    My workaround for this is to put the text fields that aren't in the first frame inside of a Movie Clip. In this way I can access them because the Movie Clips are always registered.

    I hope it helps.

    Regards,

    JC

    6 replies

    Participant
    October 9, 2018

    Thanks for the possible solution. In my case im having 200+ text buttons so creating these as movie clips is not what im willing to do. Hopefully this problem will be fixed some point or created some other way around it.

    Legend
    October 9, 2018

    If you have that many text buttons you should really be looking into creating them dynamically.

    Participant
    October 10, 2018

    Thanks for tip. I actually changed all the button text from static to dynamic. File size dropped from 10mb to less than 2mb. Bolding also works if web fonts are not used.

    Publishing takes still quite long time to run, need to find more things to optimize.

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    April 10, 2018

    Hi.

    This is something I've also been facing lately and I think it is a limitation of the CreateJS suite in Animate CC. I hope someone else can clarify this for us.

    Because what I can tell is that text fields don't get registered as children properly - or don't get registered at all - if they aren't in the first frame.

    In your case, it seems that only the first text field (lower z index) of the third frame gets registered.

    Run a test logging the exportRoot or the "this" property. You'll see that only the "txtBoxOne" and the "txtBoxTwo" are registered as children. But, if you send the "txtBoxThree" to the bottom of the stack - index 0 - you'll see it will be the one being registered.

    My workaround for this is to put the text fields that aren't in the first frame inside of a Movie Clip. In this way I can access them because the Movie Clips are always registered.

    I hope it helps.

    Regards,

    JC

    Participating Frequently
    April 10, 2018

    Thanks for the advice - turning the text into movie clips does indeed work around the problem. Definitely sounds like a bug. If anyone has any more info on this, I would appreciate it, as I am sure others that have come across this would as well.