# Random image in the gallery

**URL:** <https://forum.kirupa.com/t/random-image-in-the-gallery/319786>\
**Category:** Uncategorized\
**Created:** [March 4, 2011, 9:38am UTC](https://forum.kirupa.com/t/random-image-in-the-gallery/319786 "2011-03-04T09:38:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manuelnex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@manuelnex](https://forum.kirupa.com/u/manuelnex)\
**Post date:** [March 4, 2011, 9:38am UTC](https://forum.kirupa.com/t/random-image-in-the-gallery/319786/1 "2011-03-04T09:38:48Z")

</div>

hello  
sorry for my English but I use an automatic translator

The code below is what runs my gallery.  
I wish that the first image is random  
anyone can help me  
thank you very much  
Manuel

function initGallery()  
{  
function loadXML(loaded)  
{  
if (loaded)  
{  
xmlNode = this.firstChild;  
total = xmlNode.childNodes.length;  
for (i = 0; i \< total; i++)  
{  
small\_image\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
big\_image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
if (i == 0)  
{  
loadGImage(description\*, big\_image\*);  
} // end if  
++total\_images;  
} // end of for  
createSmall();  
downloadButton.\_visible = true;  
}  
else  
{  
content = “file not loaded!”;  
} // end else if  
} // End of the function  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;

```
xmlData.load("bars.xml?" + casuale (9999));

```

} // End of the function  
function createSmall()  
{  
smallContainer.createEmptyMovieClip(“smallImageContainer”, 10);  
var \_loc4 = 0;  
var \_loc3 = 0;  
for (var \_loc2 = 0; \_loc2 \< small\_image.length; ++_loc2)  
{  
smallContainer.imageContainer.attachMovie(“smallImage”, "smallImage_" + \_loc2, 100 + _loc2);  
m = smallContainer.imageContainer["smallImage_" + \_loc2];  
m.\_x = \_loc3 \* 50;  
m.\_y = 0;  
m.imageContainer.loadMovie(small\_image[\_loc2], 100);  
m.iData = Array();  
m.iData.big = big\_image[\_loc2];  
m.iData.title = description[\_loc2];  
++\_loc3;  
} // end of for  
smallImageContainer.\_x = 5;  
smallImageContainer.\_y = 0;  
} // End of the function  
function loadGImage(title, bigImgURL)  
{  
bigImage.imageContainer.loadMovie(bigImgURL, 100);  
bigImage.imageContainer.\_x = 0;  
bigImage.imageContainer.\_y = 0;  
title.text = title;  
downloadButton.onRelease = function ()  
{  
getURL(bigImgURL, “\_blank”);  
};  
} // End of the function

description = new Array();  
small\_image = new Array();  
big\_image = new Array();  
total\_images = 0;  
initGallery();  
var fullscreenCM = new ContextMenu(menuHandler);  
fullscreenCM.hideBuiltInItems();  
var fs = new ContextMenuItem(“Go Full Screen”, goFullScreen);  
fullscreenCM.customItems.push(fs);  
var xfs = new ContextMenuItem(“Exit Full Screen”, exitFullScreen);  
fullscreenCM.customItems.push(xfs);  
menu = fullscreenCM;  
downloadButton.\_visible = false;
