# Random Image

**URL:** <https://forum.kirupa.com/t/random-image/201028>\
**Category:** Uncategorized\
**Created:** [September 17, 2006, 10:57pm UTC](https://forum.kirupa.com/t/random-image/201028 "2006-09-17T22:57:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wayniep00p](https://avatars.discourse-cdn.com/v4/letter/w/839c29/32.png) [@wayniep00p](https://forum.kirupa.com/u/wayniep00p)\
**Post date:** [September 17, 2006, 10:57pm UTC](https://forum.kirupa.com/t/random-image/201028/1 "2006-09-17T22:57:40Z")

</div>

Hello,

I have been toying around the code for a quite some time but I haven’t been able to get it to work. In the [flash XML gallery tutorial](http://www.kirupa.com/forum/../developer/mx2004/xml_flash_photogallery.htm), how do I make the first image random (rest of the gallery will follow the regular order of p +1). The following is the actionscript to load the first image:  
[COLOR=DimGray]  
[/COLOR][SIZE=1][COLOR=DimGray]function nextImage() {

```
if (p&lt;(total-1)) {
    p++;
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        name_txt.text = name[p];
        dimensions_txt.text = dimensions[p];
        addinfo_txt.text = addinfo[p];
        addinfo2_txt.text = addinfo2[p];
        addinfo3_txt.text = addinfo3[p];
        addinfo4_txt.text = addinfo4[p];
        picture_num();
    }
    
}

```

}[/COLOR][/SIZE]

I’m thinking that I need to variable that will generate a random integer and replace that with p. Thanks guy! :kommie:  
[SIZE=1][COLOR=DimGray]

[/COLOR][/SIZE]
