I am writing a game which has a single frame main timeline. On this, there is an easelJS container which has children added to it. The children are formed of a movieclip which has an animating character within it. - What I am struggling with is:
I need to find a way that the movieclip can trigger changes in the main timeline. For instance, at present I am toggling a variable in the main timeline by detecting if the child movieclip is at a particular frame. But this feels unreliable, what I want to do is to get the movieclip timeline to toggle the property of a child by stopping at a frame.
The game loop is 'tick' based and runs through each child to time various events, but I want the child to pass back to the game loop a status change in a property. Sorry, this isn't as clear asit could be.
Any help appreciated. Thank you.
The global variable exportRoot references the main timeline.
Thank you, but how can a child know its identity to feedback to the main game loop if it is just another copy of the library object?
I need the loop to go through the container and ask each child what state it is in. Whatever code goes into the mc that is copied from the library has to be able to be fed with the mc specific identity and report back any changes.
Am I just approaching this the wrong way?
in general, other than stop() and gotoAndStop(), gotoAndPlay() all other code should be on the main timeline.
that said, you can do what you want. when you use a loop in the parent (generally looping through the child indexes), you can pass the indexes and/or child names to the main timeline.
Thank you, I think that keeping code in the main tl is sensible and I shall re-engineer the game that way!
you'll find that editing (especially when returning to a project after some days/weeks) it's much easier and faster to find and edit code that's on the main timeline and not distributed among nested movieclips.