# Random images in a loop

**URL:** <https://forum.kirupa.com/t/random-images-in-a-loop/219433>\
**Category:** Uncategorized\
**Created:** [March 16, 2007, 1:31pm UTC](https://forum.kirupa.com/t/random-images-in-a-loop/219433 "2007-03-16T13:31:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yellowmunky](https://avatars.discourse-cdn.com/v4/letter/y/f4b2a3/32.png) [@yellowmunky](https://forum.kirupa.com/u/yellowmunky)\
**Post date:** [March 16, 2007, 1:31pm UTC](https://forum.kirupa.com/t/random-images-in-a-loop/219433/1 "2007-03-16T13:31:09Z")

</div>

i have been working with this file: [http://www.kirupa.com/forum/showpost.php?p=555134&postcount=3](http://www.kirupa.com/forum/showpost.php?p=555134&postcount=3)

I got the code working from a button from the .fla posted on other page I think now but sometimes the same image presents itself when clicking one after the other.

I simply want to loop through 10 images and have them appear randomly at the click of a button. Can you also make it that it loops through the 10 images before the images appear again? i.e image 1 3 2…10…9 then another random order for the 10 images?

Was pointed to:  
last\_image\_loaded = “img04”  
when load the next image check:  
if(load\_image==last\_image\_loaded)  
{  
//generate other random number/image name  
}else  
{  
last\_image\_loaded = the name of the image you are loading  
//load image  
}

I still can’t get it to work when messing around with above idea

Any help is appreciated.

Thanks,
