# Looping for a specific no. of times(e.g 3) and go to the next frame

**URL:** <https://forum.kirupa.com/t/looping-for-a-specific-no-of-times-e-g-3-and-go-to-the-next-frame/276125>\
**Category:** Uncategorized\
**Created:** [November 23, 2008, 7:48am UTC](https://forum.kirupa.com/t/looping-for-a-specific-no-of-times-e-g-3-and-go-to-the-next-frame/276125 "2008-11-23T07:48:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![icydee](https://avatars.discourse-cdn.com/v4/letter/i/b38774/32.png) [@icydee](https://forum.kirupa.com/u/icydee)\
**Post date:** [November 23, 2008, 7:48am UTC](https://forum.kirupa.com/t/looping-for-a-specific-no-of-times-e-g-3-and-go-to-the-next-frame/276125/1 "2008-11-23T07:48:49Z")

</div>

hello there, i am experimenting with four rotating objects, the animation is perfect, my only problem is i cnt get it to stop and go on to the next frame, and the animation is called on by a separate actionscript file, i ve this code to try n stop the animation but it doesnt work, plizzzz help!

maxPlays = 3;  
// this is the max number of times i want to play it.  
if (timesPlayed == undefined) {  
var timesPlayed:Number = 1; // this is where i will keep track of how many times i have played the loop.  
}  
// this will create the counter  
if (timesPlayed \< maxPlays) { // if its less than the max number of plays  
timesPlayed++; // it plays again  
gotoAndPlay(2); // play it again  
} else { // if it has played the amount of times wanted  
stop(); // don’t play again  
}

thanks in advance!
