• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Loop timeline, then stop on a specific frame in final loop — not stopping nested movie clips

Community Beginner ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hello!

 

New to Animate, very new to JS. I've built a banner ad in the HTML5 Canvas, but I feel like I'm missing something obvious. Based on this thread, I applied the following code to the frame where I'd like my animation to stop after looping:* 

 

if (!this.looped) this.looped = 1;

if (this.looped++ == 2) this.stop();

 

I applied the action at the top level of my .fla (I have several nested movie clips and would like all to stop on a specific frame). For a while I thought it wasn't working at all, but now I see that the stop action is only effecting my background layer (not any of the other movieclips). Can anyone help me understand how to get EVERYTHING to stop simultaneously? (see image below)

 

*I would actually like to loop the animation 3 times and have it stop specifcally on frame 231 of 240, if that information is useful. I just figured I'd try the code above to start

 

 

 

TOPICS
Ad development , How to , Publish package , Timeline

Views

595

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 2 Correct answers

Community Expert , Apr 15, 2021 Apr 15, 2021

Hi.

 

To stop a Movie Clip instance and all of its chidren, set the framerate property to 0. Like this:

this.yourMC.framerate = 0;

 

Regards,

JC

Votes

Translate

Translate
Community Expert , Apr 15, 2021 Apr 15, 2021

no, any movieclip created on frame 1 (or whenever), that still exists on frame 231, can be referenced by the instance name assigned on the frame where it was created.

 

otoh, if the movieclip is tweened after creation, that can changed its instance name.

 

and further, i don't see a downside to using @JoãoCésar's suggestion:

 

if(!this.looped){

this.looped=1;

} else {

this.looped++;

if(this.looped==3){

this.framerate = 0;

}

}

Votes

Translate

Translate
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

on frame 231, use:

 

if(!this.looped){

this.looped=1;

} else {

this.looped++;

if(this.looped==3){

this.stop();

}

}

 

(which can be compressed to the code you showed, but it's, imo, foolish to do so.)

Votes

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
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Thanks for the help! But alas — I applied this code, and got the same results. The only thing that stopped was the background layer. (see screencap here)

 

I had been looking into this thread and wondered if I needed to specifically add a stop for each movie clip instance (which seems tedious and like it's probably not necessary, but what do I know). Thoughts?

Votes

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
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

that will stop the timeline that it's added to.  if that code is on frame 231 of the main timeline and there are movieclips on frame 231 of the main timeline, they need to be stopped too.  ie, if there are movieclips mc1 and mc2 on the main timeline where you want everything to stop use:

 

if(!this.looped){

this.looped=1;

} else {

this.looped++;

if(this.looped==3){

this.stop();

this.mc1.stop();

this.mc2.stop();

}

}

Votes

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
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

OK, I think follow what you're saying. That still didn't work, but I think I understand why: It's because my movieclips technically *aren't* on frame 231 of the main timline (right?). Those movieclips only appear on frame 1 of the main timeline (everything else on the main timeline is just frames)*, so I need to go into each movieclip and insert the code snippet where I want each of those animations to stop. Is that correct?

 

For example, a movieclip that is on the "background" layer (motorcycleBG_mc) contains three additional movieclips for the animating circles. To get these to stop, I had to paste your original code snippet within the "motorcycleBG_mc" movieclip

 

*It's also entirely possibly that I built this whole ad not using best practices. Still learning!

 

Votes

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
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

no, any movieclip created on frame 1 (or whenever), that still exists on frame 231, can be referenced by the instance name assigned on the frame where it was created.

 

otoh, if the movieclip is tweened after creation, that can changed its instance name.

 

and further, i don't see a downside to using @JoãoCésar's suggestion:

 

if(!this.looped){

this.looped=1;

} else {

this.looped++;

if(this.looped==3){

this.framerate = 0;

}

}

Votes

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
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Thanks for clarifying. I think I may have done some things out of order re: when and how I changed instance names on my movieclips, so maybe that's why the second code snippet you provided didn't stop anything other than the background. I'm hoping to develop a better workflow as I go.

 

BUT, the last snippet you provided with @JoãoCésar's suggestion worked like a charm. Thank you both SO MUCH!

Votes

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
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

you're welcome.

Votes

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
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Hi.

 

To stop a Movie Clip instance and all of its chidren, set the framerate property to 0. Like this:

this.yourMC.framerate = 0;

 

Regards,

JC

Votes

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
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

This worked when combined with @kglad's suggestions above. Thanks so much!

Votes

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
Community Expert ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

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