Movieclip in EaselJS container to trigger main timeline

New Here ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

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.

 

TOPICS
Code, Timeline

Views

97

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 22, 2021 Feb 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.

Likes

Translate

Translate
Adobe Community Professional ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

The global variable exportRoot references the main timeline.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Thank you, I think that keeping code in the main tl is sensible and I shall re-engineer the game that way!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

 

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines