# Loading a Random SWF movie

**URL:** <https://forum.kirupa.com/t/loading-a-random-swf-movie/296984>\
**Category:** flash\
**Created:** [September 23, 2009, 6:42pm UTC](https://forum.kirupa.com/t/loading-a-random-swf-movie/296984 "2009-09-23T18:42:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaisho](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaisho](https://forum.kirupa.com/u/kaisho)\
**Post date:** [September 23, 2009, 6:42pm UTC](https://forum.kirupa.com/t/loading-a-random-swf-movie/296984/1 "2009-09-23T18:42:18Z")

</div>

Hi there.

I am really new to Flash. I have just read the tutorial “**[FONT=Verdana][SIZE=4][COLOR=#003366]Loading[/COLOR][/SIZE][/FONT]**[FONT=Verdana][SIZE=4][COLOR=#003366] a Random Background” [/COLOR][/SIZE][/FONT]I was hoping that this would help me be able to load SWF files, which in themselves are short movies, on the click of a button.

I have all the SWF files and the FLA file in the same folder as per the instructions, and labled likewise.

However when I try to play this movie, all I get is the main SWF movie, it doesn’t want to load the other random movies.

Code used on a button is:-

on (release)  
{  
choice = Math.round(Math.random()\*43);  
switch (choice)  
{  
case 0 :  
location.loadMovie(“Image0.swf”);  
break;  
…  
case 43 :  
location.loadMovie(“Image43.swf”);  
break;  
}  
}

Where have I gone wrong, help is very much needed and appriciated.

Note this is not for a website application, only for locale machine, for presentations.

Thanks
