1

I've created a MovieClip Symbol in AnimateCC which is made up of other MovieClip Symbols. I want to iterate through the children of the parent MovieClip at runtime to amend some of the child symbols properties. I thought it would be easy using something like :-

for (var i= 0; i < this.MyThing.getNumChildren(); i++) {
    var child = this.MyThing.getChildAt(i);
    // then amend child properties
}

But this doesn't work. When I look in the js file it seems that the children are added as properties of the instance e.g.

this.T1 = new lib.Thing1();

rather than how you'd add children normally like:-

var PA = new lib.Thing1();
this.ParentThing.addChild(PA);

So is there a way of getting at the child objects dynamically at run time by iterating through children rather than hardcoding the names of the child MovieClips?

Jonsij
  • 11
  • 2

1 Answers1

3

There was a bug introduced to Animate when Adobe changed all single-frame timelines from Containers to MovieClips, and children are not immediately available. Children of MovieClips are added to the timeline via Tween timelines. There should be an addChild call in the constructor, but there is not.

You can get around this by calling gotoAndStop(0) and then iterating the children.

this.gotoAndStop(0);
console.log(this.children);

Hope that solves your issue. Hopefully this gets solved in the next Adobe Animate release.

Lanny
  • 11,244
  • 1
  • 22
  • 30