How do I cycle through SWFs?

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, and just followed that instead.

My question is, how can I modify this banner setup 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.

i’m no guru either, but you seemed pretty desperate over here, so here’s my newbie work around method:

remember this part?

_root.currMovie = "your_first_section_name"; 

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.


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

_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

_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:

_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:

if(_root.manual == 1) {
} else {
_root.currMovie = "2nd_movie";

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 :slight_smile:
dang i feel like i’ve written about half a tutorial.[/SIZE]

thanks hsadan for writing such a good post. i’ll try all that out right now. that should give me enough direction. thanks

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

if (_currentframe !=1 && _currentframe == totalframe){
unload playing movie
load your next movie

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.


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