Loop timeline then play frame label

New Here ,
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

76

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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. 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
shane.h.2021 AUTHOR LATEST
New Here ,
Jan 13, 2021

Copy link to clipboard

Copied

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');
}

Likes

Translate

Translate

Report

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