# \[FMX\] looping MC xtime

**URL:** <https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370>\
**Category:** flash\
**Created:** [December 10, 2002, 3:33pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370 "2002-12-10T15:33:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melissa\_Anne](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Melissa\_Anne](https://forum.kirupa.com/u/Melissa_Anne)\
**Post date:** [December 10, 2002, 3:33pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/1 "2002-12-10T15:33:47Z")

</div>

Hi,

I need the actionscript code to loop my MC 6 times and then stop at the last frame of this MC.  
Can anyone help me?  
Thanx !

[COLOR=silver][SIZE=1]Moved by h88 - Please post in the right forum next time.[/SIZE][/COLOR]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 3:39pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/2 "2002-12-10T15:39:40Z")

</div>

Just create a counter variable and on the last frame of your movie put

```auto

if (counter < 6){
	counter += 1;
	gotoAndPlay(1);
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 4:05pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/3 "2002-12-10T16:05:59Z")

</div>

add a blank frame in the begining of the movie with this script on it:

```php

this_loop = 0

```

this script goes on the last frame:

```php
loops = 6 // or the number of times you want the movie to loop.
if (this_loop==6){
        stop();
} else {
        gotoAndPlay(2)
}
this_loop +=1

```

there’s a variable “this\_loop” that adds 1 whenever one loops is completed, and the if statement check whether the value of that value is 6…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 4:07pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/4 "2002-12-10T16:07:29Z")

</div>

ack, i forgot to add a stop(); make sure you do that

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 4:09pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/5 "2002-12-10T16:09:28Z")

</div>

A few questions-

Is that the last frame of the movie clip or the main timeline (and)

I have on the first frame of the movie clip counter = 0

…and since it doesn’t work I need a little more input…

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 4:12pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/6 "2002-12-10T16:12:45Z")

</div>

it should be on the last frame of your Movie Clip, also you need to start the variable some place where it won’t execute that code again, if it’s on the first frame and you are looping back to that it will reset the variable to 0 every time. If you don’t specify what the variable is at first when it hits the counter it will assume it is 0 and change it to 1 and go from there.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 4:43pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/7 "2002-12-10T16:43:22Z")

</div>

thank u all …it works now!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 5:42pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/8 "2002-12-10T17:42:47Z")

</div>

on actions layer, frame 1 inside my movie clip I have:

counter

on the last frame of an animation layer inside the same mc I have:

if (counter \< 4){  
counter += 1;  
gotoAndPlay(“frmStart”);  
}

(and) it is still not stopping as desired…

Thanks :sigh:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2002, 7:04pm UTC](https://forum.kirupa.com/t/fmx-looping-mc-xtime/9370/9 "2002-12-10T19:04:34Z")

</div>

add a stop(); command after your if statement, i forgot to add it in my original post.
