• 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 play frame label

New Here ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

Hello Everyone,

 

This is my first post and I'm not really a programer so please go easy on me. I'm trying to loop my timline from frame 1 to frame 253 and then once it has reached two loops it goes to and plays a Frame Label. The code below is what I've placed at frame 253 and it loops but it just loops continuosly once it hits frame 253. Can anyone sugest an edit to get this snippet to work correctly? Thanks very much!

 

this.loopsPlayed++; console.log(this.loopsPlayed);
 
if (this.loopsPlayed >= 2) {
this.gotoAndPlay('_end');
} else {
this.gotoAndPlay(0);
}

 

 

TOPICS
ActionScript , Code , Timeline

Views

157

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 ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

If you assign your loopsPlayed to a value of 0 or whatever in a previous keyframe (0?) - be SURE that the playhead never hits that frame again or else it'll reset the value to 0 each time. 

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
New Here ,
Jan 13, 2021 Jan 13, 2021

Copy link to clipboard

Copied

LATEST

Thanks Joseph! I wasn't sure where my script was wrong. I used a script from another banner and modified it to use frame labels instead of frame numbers. It works now! Loops twice and then plays my end animation. Thanks for your help! BTW, I've been watching your tutorials for a long time, big fan!

 

if (!this.looped) this.looped = 1;
if (this.looped++ == 2) this.gotoAndPlay('_end');
else {
this.gotoAndPlay('_start');
}

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