# Help needed with a random image script

**URL:** <https://forum.kirupa.com/t/help-needed-with-a-random-image-script/201191>\
**Category:** flash\
**Created:** [September 19, 2006, 8:23am UTC](https://forum.kirupa.com/t/help-needed-with-a-random-image-script/201191 "2006-09-19T08:23:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skellz](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@Skellz](https://forum.kirupa.com/u/Skellz)\
**Post date:** [September 19, 2006, 8:23am UTC](https://forum.kirupa.com/t/help-needed-with-a-random-image-script/201191/1 "2006-09-19T08:23:55Z")

</div>

Hello people, i was wondering if someone could possibly lend me a hand. I have this great idea which i have begun implimenting on my website but i have currently hit a brick wall. The idea is to have three images on the home page. Every time the page is reloaded the images change to a new random image (from a defined array of images). But…and this is the problem…there are THREE of these images. I need the images to both not repeat themselves nor have the same displayed in two images. For example, i dont want images 1/2/3 to be proceeded by images 1/2/3 (in any order), nor do i want images 1/2/2 displayed. Always three new images.

This is the code i am currently using, is slightly adapted from another i found on the web.

* * *

fscommand(“allowscale”, “true”);

//Preload Function  
\_root.bar.\_visible = 0;  
\_root.barBorder.\_visible = 0;

MovieClip.prototype.loadPic = function(pic) {

this.loadMovie(pic);  
this.\_parent.onEnterFrame = function() {  
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();  
var t = containerMC1.getBytesTotal(), l = containerMC1.getBytesLoaded();  
var t = containerMC2.getBytesTotal(), l = containerMC2.getBytesLoaded();  
bar.\_visible = 1;  
barBorder.\_visible = 1;  
per = Math.round((l/t)\*100);  
if (t != 0 && Math.round(l/t) == 1 && “containerMC”, “containerMC1”, “containerMC2”.\_width != 0) {

bar.\_visible = 0;  
barBorder.\_visible = 0;  
loadText3.text = “”;  
delete this.\_parent.onEnterFrame;  
} else {  
bar.\_width = per \* 2;  
loadText3.text = per+" % loaded";  
}  
};  
};

//Random images  
pics = new Array(“park2.jpg”, “park5.jpg”, “park8.jpg”, “park12.jpg”);  
var randNum = getRandom(0, 3);  
\_root.containerMC.loadPic(pics[randNum],pics[randNum],100);  
\_root.containerMC1.loadPic(pics[randNum],pics[randNum],100);  
\_root.containerMC2.loadPic(pics[randNum],pics[randNum],100);  
pics[randNum].\_x = 0;  
pics[randNum].\_y = 0;  
// function to generate a random integer  
// between minimum and maximum, inclusively  
function getRandom(minimum, maximum) {  
return Math.floor(Math.random()\*3(maximum-minimum+1)+minimum);  
}

* * *

If anyone could help by modifying this code that would be awesome. Thanks alot.

Skellz  
:cowboy:
