# Random Image gallery

**URL:** <https://forum.kirupa.com/t/random-image-gallery/192955>\
**Category:** flash\
**Created:** [July 3, 2006, 5:29am UTC](https://forum.kirupa.com/t/random-image-gallery/192955 "2006-07-03T05:29:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [July 3, 2006, 5:29am UTC](https://forum.kirupa.com/t/random-image-gallery/192955/1 "2006-07-03T05:29:38Z")

</div>

I am trying to upgrade my image gallery.

I have an image gallery of 25 images created and named image101, image 102, ect…  
The images are loaded dynamically from a list of 100 images. I can easily pick the images randomly and load them into a gallery.

I have two problems…

1. I can either get the gallery to format correctly or when selected select the correct images. I can’t seen to get both to work refer to swf’s.

2. once a number is selected I do not want the same number selected again so I don’t the sames images more then once. This is of little concern because eventually I will have such a large pool of images to choose from but I am curious how it is done.

```auto
function gallery () {
    for (var i = 101; i < numberOfImages; i++) {
        // **********************************
        var randomNum:Number = Math.floor (Math.random () * (numberOfImages - startingNumber)) + startingNumber;
        // **********************************
        this.attachMovie ("image", "image" + i, i);
        this.myMCL.loadClip ("image" + randomNum + ".jpg", this["image" + i].painting);
        this["image" + i]._alpha = 100;
        this["image" + i]._x = 40;
        this["image" + i]._y = 50;
        if (this["image" + (i - 1)]._x > 175) {
            this["image" + i]._y = this["image" + (i - 1)]._y + 100;
            this["image" + i]._x = 40;
        } else {
            this["image" + i]._x = this["image" + (i - 1)]._x + 100;
            this["image" + i]._y = this["image" + (i - 1)]._y;
        }
    }
}

```
