# Making random backgrounds more random w AS

**URL:** <https://forum.kirupa.com/t/making-random-backgrounds-more-random-w-as/123069>\
**Category:** Uncategorized\
**Created:** [September 20, 2004, 5:52am UTC](https://forum.kirupa.com/t/making-random-backgrounds-more-random-w-as/123069 "2004-09-20T05:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerosignal0](https://avatars.discourse-cdn.com/v4/letter/z/8edcca/32.png) [@zerosignal0](https://forum.kirupa.com/u/zerosignal0)\
**Post date:** [September 20, 2004, 5:52am UTC](https://forum.kirupa.com/t/making-random-backgrounds-more-random-w-as/123069/1 "2004-09-20T05:52:08Z")

</div>

Hello,  
Im working on my site and I have a random background script setup. Heres the code that Im using now.

```auto
 choice = Math.round(Math.random()*4);
 switch (choice) {
case 0 :
 _root.background.loadMovie("background1.swf");
 break;
case 1 :
 _root.background.loadMovie("background2.swf");
 break;
case 2 :
 _root.background.loadMovie("background5.swf");
 break;
case 3 :
 _root.background.loadMovie("background7.swf");
 break;
case 4 :
 _root.background.loadMovie("background8.swf");
 break;
} 

```

Now I love the way thats its working and but one thing that is kinda crappy is that sometimes it suffers from repeating the same background a couple of times before going to another random background. Now I know that its because the script is working properly but can anyone think of a method that I could use to make it not be able to pull up the last background that it has already loaded? I dont want to make it static because not only do I have this setup for when you enter the site but also its random when you click on one of the nav buttons because I want to try to keep my site dynamic.

Any ideas?  
Thanks in advance.
