# Automaticly load & play SWFs

**URL:** https://forum.kirupa.com/t/automaticly-load-play-swfs/62313
**Category:** flash
**Created:** [August 26, 2004, 7:36pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313 "2004-08-26T19:36:17Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![audifax](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@audifax](https://forum.kirupa.com/u/audifax)
#### Post date: [August 26, 2004, 7:36pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/1 "2004-08-26T19:36:17Z")

</div>

Hi Guys,

I am busy with making a flash movie/animation with different chapters in it. So, I’ve made a couple of chapters and published it as a SWF file for every chapters.  
I can easliy load and play the 1st chapter/swf in the Main.swf but how can I automaticly load and play the 2nd chapter/swf after the 1st chapter finished?

Any ideas?

---

<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 26, 2004, 8:06pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/2 "2004-08-26T20:06:20Z")

</div>

just load it in the same way you did the first swf, it should work the same I think

you might have use unload movie but I think if you load it into the same level it takes its place anyway

look at this for example:  
[http://www.kirupa.com/developer/mx/full\_site.htm](http://www.kirupa.com/developer/mx/full_site.htm)

---

<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 26, 2004, 8:27pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/3 "2004-08-26T20:27:47Z")

</div>

Jillymo,

This is how I play the first swf (the action of the firstframe of Main.swf)

loadMovieNum(“01.swf”, 1);

If i put loadMovieNum(“02.swf”, 1); in the second frame of Main.swf and test the Main.swf it skipped the first frame and play 02.swf directly…

---

<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 27, 2004, 6:09am UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/4 "2004-08-27T06:09:20Z")

</div>

at the last frame of 01.swf , place loadMovieNum(“02.swf”, 1);

it should work.

---

<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 27, 2004, 6:25pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/5 "2004-08-27T18:25:10Z")

</div>

did you try wheel’s suggestion- did it work?

---

<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 27, 2004, 8:10pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/6 "2004-08-27T20:10:41Z")

</div>

yeah, ive just tried wheel’s suggestion and it works…  
But that means that I have to put the loadMovieNum(“02.swf”, 1); script at the end of every chapters…  
Is there any posibility to have loadMovieNum(“02.swf”, 1); central on Main.swf?  
Maybe put it in an array variable or something like that?

Thanks guys!

---

<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 27, 2004, 8:17pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/7 "2004-08-27T20:17:07Z")

</div>

how about \_root.chapters.unloadmovie();//this will unload what ever chapter is playing  
and \_root.chapters.loadmovie(“02.swf”);//this will load the new chapter  
btw - chapters is the instance name of the MtMC  
when you do that you have more control of the chapter loading and unloading, frame control and all the other mumbo jumbo

will that work for you?!

---

<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 27, 2004, 9:04pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/8 "2004-08-27T21:04:51Z")

</div>

what we need to do here is check for the last frame playing in each chapter.  
to do this, we can use a logical test and see if the current frame, \_currentframe, is equal to the last frame, \_totalframes. then, we can load the next chapter.

to know what chapter to load next, we keep a variable that tells us the current chapter and when the last frame is reach ed of that chapter, we add one to the chapter variable and we can load the next chapter.

for example, the first chapter may be named:  
"chapter\_1.swf"  
and the second  
"chapter\_2.swf"  
third  
"chapter\_3.swf"  
etc…

and then we can load these movieclips into another.  
I’ve attached one so that you can see it in action.

you’ll need to uncomment the lines of code that load the movies, and add in some more code if this does not suit you 🙂

---

<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:02pm UTC](https://forum.kirupa.com/t/automaticly-load-play-swfs/62313/9 "2004-08-30T19:02:10Z")

</div>

guys,

thanks for the replies…  
what i really trying to do is (see image attached) to build a cd-rom promo something like that…

You’ll see red and blue arrows in the image attached.  
Red means that the next chapter#.swf will load/play automaticly and ofcourse unload/stop the chapter played before.

Blue means that I’ll put a button in Main.swf to play the clicked chapter.  
I’d like to put all the script on Main.swf if its possible…

I’m new with FlashMX… maybe is easy to do this for you guys… but i’ve tried many things and i’ve searched on the net but still stuck with this.  
Any idea? Your help will be much appreciated!!
