Skip to main content
PhilipRichardson
Participant
February 21, 2021
Answered

Movieclip in EaselJS container to trigger main timeline

  • February 21, 2021
  • 1 reply
  • 660 views

Hello

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.

 

This topic has been closed for replies.
Correct answer kglad

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.

1 reply

Legend
February 22, 2021

The global variable exportRoot references the main timeline.

Participant
February 22, 2021

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?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 22, 2021

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.