# \[F5\] random movie shuffling

**URL:** <https://forum.kirupa.com/t/f5-random-movie-shuffling/18581>\
**Category:** flash\
**Created:** [April 18, 2003, 7:56am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581 "2003-04-18T07:56:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![darklogik\_org](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@darklogik\_org](https://forum.kirupa.com/u/darklogik_org)\
**Post date:** [April 18, 2003, 7:56am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581/1 "2003-04-18T07:56:56Z")

</div>

Hi, I’ve been designing this interface for my site. It contains a mini-tv thing in the corner that plays external flash movies selected at random from a list and loaded into an empty MC (“external\_screen”) with “loadMovie”.

the code is as follows

onClipEvent (load) {  
movieList = [“technical\_fault”, “skag”];  
\_root.external\_screen.loadMovie(movieList[Math.floor(Math.random()\*movieList.length)]+".swf");

}

where “technical\_fault” and “skag” are external swf files

How do I make it so that when a movie finishes, the previous code is run again and a new movie is selected?

cheers

---

<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:** [April 18, 2003, 8:08am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581/2 "2003-04-18T08:08:35Z")

</div>

I would make it a function like so

```auto

movieList = ["technical_fault", "skag"]; 
tvScreenLoader = function(){
  _root.external_screen.loadMovie(movieList[Math.floor(Math.random()*movieList.length)]+".swf"); 
}

```

that would go into one of the first frames of your main movie.

Then, each external swf that is being loaded, should have on it’s last frame  
\_root.tvScreenLoader();

the function will be called each time a movie finishes, loading a new one into the tv.

---

<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:** [April 18, 2003, 8:11am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581/3 "2003-04-18T08:11:04Z")

</div>

nice one mate, the code’s been through four changes, i think this is the best one so far!

thanks again

---

<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:** [April 18, 2003, 8:17am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581/4 "2003-04-18T08:17:21Z")

</div>

slight problem here, the code loads the first movie, which plays, but then for some reason when the external movie gets to the last frame it doesn’t seem to activate the \_root.tvScreenLoader to load the 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:** [April 18, 2003, 8:40am UTC](https://forum.kirupa.com/t/f5-random-movie-shuffling/18581/5 "2003-04-18T08:40:53Z")

</div>

nope, my mistake, fixed it.

thanks a lot! 🙂
