# Use Random without getting the Same Number Twice

**URL:** https://forum.kirupa.com/t/use-random-without-getting-the-same-number-twice/293726
**Category:** flash
**Created:** [August 2, 2009, 7:16pm UTC](https://forum.kirupa.com/t/use-random-without-getting-the-same-number-twice/293726 "2009-08-02T19:16:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![remyzero](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@remyzero](https://forum.kirupa.com/u/remyzero)
#### Post date: [August 2, 2009, 7:16pm UTC](https://forum.kirupa.com/t/use-random-without-getting-the-same-number-twice/293726/1 "2009-08-02T19:16:48Z")

</div>

Hello, I’m new around here. I was wondering if anyone could help solve my dilemma. I’m building a dynamic Grid Gallery in AS2 consisting of 35 image spaces with over a 100 images to select from. I want the images to be selected randomly, but don’t want any of the images to repeat. This is the code I have for the Randomnization.  
I figured that if the imageNumber equaled itself then it would continue to randomize until it did not equal it self, but this is not the case. Thanks!

```auto
function loading_function(a:Number){
    
    imageNumber = Math.floor(Math.random() * 100);
    
    trace("this variable equals..." + a);
    
    var myLoader:MovieClipLoader = new MovieClipLoader();
    var myListener:Object = new Object();
    
        myListener.onLoadStart = function(){
            trace("this box has started loading");
        }
        myListener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number){
            percent = Math.floor(bytesLoaded/bytesTotal * 100);
        }
        myListener.onLoadError = function(target:MovieClip){
            eval("box" + a);
            
        }
        myListener.onLoadInit = function(target:MovieClip){
            trace("successfully loaded");
            eval("box" + a);
            
            
            
        }
        
        
    myLoader.addListener(myListener);
    myLoader.loadClip("thumbs/thumb" + imageNumber +".jpg", "box" + a + ".targetBox");
    
    if(imageNumber == imageNumber){
        imageNumber = Math.floor(Math.random() * 99) + 1;
    } else {
        imageNumber = imageNumber;
    
    }
}

```
