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

Dynamic text update problem

Explorer ,
Apr 09, 2018 Apr 09, 2018

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?

2.3K
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 , Apr 10, 2018 Apr 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

...
Translate
Community Expert ,
Apr 10, 2018 Apr 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

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
Explorer ,
Apr 10, 2018 Apr 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.

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 Beginner ,
Oct 09, 2018 Oct 09, 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.

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
LEGEND ,
Oct 09, 2018 Oct 09, 2018

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

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 Beginner ,
Oct 09, 2018 Oct 09, 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.

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
LEGEND ,
Oct 10, 2018 Oct 10, 2018
LATEST

kaspers42  wrote

Thanks for tip. I actually changed all the button text from static to dynamic.

That's... not at all what I meant.

I meant generate the buttons with code instead of manually making 200+ buttons.

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