# How to loop external .swf movies

**URL:** <https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694>\
**Category:** Uncategorized\
**Created:** [August 30, 2004, 5:30pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694 "2004-08-30T17:30:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![markP](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@markP](https://forum.kirupa.com/u/markP)\
**Post date:** [August 30, 2004, 5:30pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/1 "2004-08-30T17:30:24Z")

</div>

I have a bunch of external SWF movies that I need to loop through, how can I do this. In other words I need each movie to play, movie1.swf, movie2.swf, etc. then once the last one in the group is done it starts over at movie1 again and just keeps doing it.

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:** [August 30, 2004, 5:40pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/2 "2004-08-30T17:40:15Z")

</div>

Well if you are loading the externals into a main via loadMovie then just load the next movie at the end of the previous movie’s animation. In other words, load the first external. At the end of the animation in that external use loadMovie(“external2.swf”) etc. On the last external reload the 1st external and you’ll be looping forever.

:hr:

---

<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:** [August 30, 2004, 5:59pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/3 "2004-08-30T17:59:37Z")

</div>

Yes, that would be the nice/easy way to handle it. But I don’t have access to the FLAs for the external SWFs so I have to write it in the code in the main movie.

---

<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:** [August 30, 2004, 6:17pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/4 "2004-08-30T18:17:23Z")

</div>

That’s a bummer. ☹ Well I guess you could figure out how long each external swf plays for and then use setInterval in your main script. Kind of a pain but it will work with some trial and error.

:hr:

---

<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:** [August 30, 2004, 6:26pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/5 "2004-08-30T18:26:26Z")

</div>

load the swf into a movieclip that is put onto the stage at design time, and then add this code to the movieclip:

```auto
onClipEvent(enterFrame) {
   if (this._currentframe == this._totalframes) {
      this.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:** [August 30, 2004, 7:59pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/6 "2004-08-30T19:59:06Z")

</div>

Here’s what I ended up with. It works but I know theres got to be a better way to write it so I don’t have to write 15 different “if” loops. But, like I said, it works.

Thanks

```auto
dropZone1.loadMovie ("windows1.swf");
title_txt = "Windows - Appearance";
onEnterFrame = function () {
	if (dropZone1._currentframe == dropZone1._totalframes - 1) {
		dropZone1.unloadMovie ();
		title_txt = "Windows - Start Menu";
		dropZone2.loadMovie ("windows2.swf");
	}
	if (dropZone2._currentframe == dropZone2._totalframes - 1) {
		dropZone2.unloadMovie ();
		title_txt = "Windows - My Computer";
		dropZone3.loadMovie ("windows3.swf");
	}
	if (dropZone3._currentframe == dropZone3._totalframes - 1) {
		dropZone3.unloadMovie ();
		title_txt = "Windows - My Documents";
		dropZone4.loadMovie ("windows4.swf");
	}
ETC.

```

---

<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:** [August 30, 2004, 9:02pm UTC](https://forum.kirupa.com/t/how-to-loop-external-swf-movies/62694/7 "2004-08-30T21:02:11Z")

</div>

```auto
dropZone1.loadMovie ("windows1.swf");
title_txt = "Windows - Appearance";
//
//This is the array that you'll need to put all of the title_txt values into.
myArray = new Array();
myArray[1] = "This is the title_txt value you'd like to be displayed when dropTarget1 reaches the end";
myArray[2] = "for dropTarget2";
myArray[3] = "etc...";
//
numberOfDropTargets = 5; //edit this so that it is equal to the number of droptargets in the dynamically loaded swf
//
onEnterFrame = function () {
    for (i = 1; i <= numberOfDropTargets; i++);
        if (this["dropTarget"+i]._currentframe == this["dropTarget"+i]._totalframes - 1) {
            this["dropTarget"+i].unloadMovie();
	    title_txt = myArray*;
            this["dropTarget"+(i+1)].loadMovie ("windows"+(i+1)+".swf";
        }
     }
}

```

I did this in notepad, so you may need to debug it slightly 😉 sorry for any inconvenienve caused.
