# How do I cycle through SWFs?

**URL:** https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442
**Category:** flash
**Created:** [September 7, 2004, 1:04am UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442 "2004-09-07T01:04:40Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![redrum87](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@redrum87](https://forum.kirupa.com/u/redrum87)
#### Post date: [September 7, 2004, 1:04am UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/1 "2004-09-07T01:04:40Z")

</div>

Hey all,

I was well on my way creating a Flash banner with 4 different buttons which users could press to select different SWF files for viewing. [Then I found this tutorial on kirupa](http://www.kirupa.com/developer/mx2004/transitions.htm), and just followed that instead.

**My question is, how can I modify [this banner setup](http://www.kirupa.com/developer/mx2004/transitions.htm) so that it cycles through the 4 different SWF files without user intervention?** On top of that though, I want the users to be able to stop the cycle and, if they’d like, be able to choose a specific ad.

I’m no actionscript guru, but I’m thinking its something along the lines of when an SWF reaches a certain frame, it load the next one. However, when one swf ends and the next one begins, will the first one close so it doesn’t take up the processor?

Thanks in advance.

---

<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: [September 7, 2004, 8:50am UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/2 "2004-09-07T08:50:45Z")

</div>

i’m no guru either, but you seemed pretty desperate over [here](http://kirupaforum.com/forums/showthread.php?t=69007), so here’s my newbie work around method:

remember this part?

```auto
_root.currMovie = "your_first_section_name"; 
container.loadMovie(_root.currMovie+".swf"); 

```

you are instructed to place this on the first frame, so that when your movie starts playing (ie moves to the first frame) this action will be executed, thus loading the first\_section movie.  
pretty simple, you got this part, right? now onto solving your problem.

```auto
_root.container.loadMovie(_root.currMovie+".swf"); 

```

the above code is placed at the ends of your nth\_section movie. here’s a brief explanation:  
when the movie reaches this frame, it instructs the container mc symbol in your main movie to load \_root.currMovie . \_root.currMovie, if you remember, is set depending on which button the user clicks (eg if he clicks “home”, this is set to “home”)  
therefore, what you need to do is to define \_root.currMovie to be your second movie. this can be done automatically by adding in

```auto
_root.currMovie = "2nd_movie";

```

**before** \_root.container.loadMovie(\_root.currMovie+".swf"); .

that’s about it.

as for the stopping and manual selection…  
put in the first frame of your timeline

```auto
_root.manual = 0;

```

this sets the variable \_root.manual to 0

create a button for the user to click (to stop)  
then give it the following actions:

```auto
on(release){
_root.manual = 1;
}

```

self-explanatory, when the button is clicked \_root.manual is set to 1

now go into your individual movies to be loaded, and on the last frame put your code within an if() condition, such that your code looks something like this:

```auto
if(_root.manual == 1) {
stop();
} else {
_root.currMovie = "2nd_movie";
_root.container.loadMovie(_root.currMovie+".swf");
}

```

explanation: the movie checks to see if \_root.manual is set to 1, if it is, it stops and does not execute the action to load the next movie. if \_root.manual is not set to 1, it executes the required actions.

to summarize it, when the user clicks on the stop button, he sets the variable ‘manual’ to 1. at the end of each movie, flash checks to see if ‘manual’ is at 1 or not. if it is, it stops there; if it isn’t, it loads the next movie.

finally, for the changing manually part:  
simply create buttons to define \_root.currMovie to the respective movies, as in the tutorial.

[SIZE=1]i have yet to try this out, and due to my inexperience, somebody please point out if anything is wrong 🙂  
dang i feel like i’ve written about half a tutorial.[/SIZE]

---

<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: [September 7, 2004, 4:29pm UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/3 "2004-09-07T16:29:31Z")

</div>

thanks hsadan for writing such a good post. i’ll try all that out right now. that should give me enough direction. 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: [September 7, 2004, 7:16pm UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/4 "2004-09-07T19:16:40Z")

</div>

Really brief here…  
load the first swf  
get its currentframe and its totalframes.  
in general…  
if (\_currentframe !=1 && \_currentframe == totalframe){load your next movie}  
this will have to be set on enterFrame or clipEvent or setInterval to constantly check the \_currentframe of the swf you loaded. this method allows you to put NO additional code in the external swfs you are loading…sorry so quick hope this helps…ipaq

---

<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: [September 7, 2004, 7:18pm UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/5 "2004-09-07T19:18:28Z")

</div>

p.s  
if (\_currentframe !=1 && \_currentframe == totalframe){  
unload playing movie  
load your next 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: [September 7, 2004, 7:20pm UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/6 "2004-09-07T19:20:09Z")

</div>

Just a quick addition FYI - whenever you use loadMovie to load an external swf into a container clip it will replace whatever is currently there, as opposed to just sitting on top of it.

: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: [September 9, 2004, 5:56am UTC](https://forum.kirupa.com/t/how-do-i-cycle-through-swfs/63442/7 "2004-09-09T05:56:01Z")

</div>

thanks guys. you’ve all been a big help.
