0

So I have a bunch of movie clips on the main timeline but using numChildren property always returns 0 because the code generated by Adobe Animate adds them to the main timeline using addTween() and numChildren only work when children are added to parent using addChild(). As of now I have to "hack" it by accessing the timeline._tweens, then loop through every tween to get the child I want. I don't like doing it this way. So what is the best way to access the children?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DT DT
  • 378
  • 2
  • 6
  • 16

1 Answers1

1

After I dig through a few documents online, and here is what I found. When children added to timeline using tween timelines, Adobe should add an addChild() call in constructor but somehow it left out. And this is a bug. So to go around this bug, we just need to call gotoAndStop(0) first, then we can use the numChildren or children properties.

DT DT
  • 378
  • 2
  • 6
  • 16
  • Also similarly, if you want to call a variable being used on nth frame. You cannot call it unless gotoAndStop(n) is called first. Ideally, using gotoAndStop(0) to use a variable defined on 1st frame does not make sense because it is supposed to be called automatically. – Vishwas Sep 10 '21 at 18:46