exportRoot returning inconsistent number of children
Here's my scenario: I'm trying to use nominalBounds to store a width and height property on all the objects I've added to the stage at the start of my animation. To do this I have this function
function storeBounds(i)
{
var bounds = i.nominalBounds;
i.width = bounds.width;
i.height = bounds.height;
}which works fine when I feed it one object at a time, but I want it to just automatically run on everything that's on the stage. So my first thought was to simply use a for loop and run this function on all the children of exportRoot, which is where I've run into my issue.
- If I try to access exportRoot.numChildren from code on the main timeline it returns 0 children.
- If I try to access exportRoot.numChildren by adding code to the fnStartAnimation function Adobe Animate creates it returns 0 children
- if I instead add console.log(exportRoot.children) to the fnStartAnimation function, it returns an array that does actually have all the children in it, but still claims to have 0 children whether I ask for exportRoot.numChildren or exportRoot.children.length
- if I bring up the dev console in chrome and acces exportRoot.numChildren once the animation is running it returns the correct number for however many objects I've added to the stage
So my question is, what am I doing wrong here? Why is exportRoot returning conflicting information about it's number of children. Is there a better way I should be going about this? I realize I could just make an array and manually log every object I add to the stage into it and then run my storeBounds function on that array, but it seems like a lot of unneccessary work on my part when there is already an array of all the objects on stage in exportRoot.
Any advice is greatly appreciated.
Thank you.
