# Trying to display 2 random images in a single frame

**URL:** https://forum.kirupa.com/t/trying-to-display-2-random-images-in-a-single-frame/277715
**Category:** Uncategorized
**Created:** [December 16, 2008, 10:53am UTC](https://forum.kirupa.com/t/trying-to-display-2-random-images-in-a-single-frame/277715 "2008-12-16T10:53:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![thehungrymonkey](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@thehungrymonkey](https://forum.kirupa.com/u/thehungrymonkey)
#### Post date: [December 16, 2008, 10:53am UTC](https://forum.kirupa.com/t/trying-to-display-2-random-images-in-a-single-frame/277715/1 "2008-12-16T10:53:03Z")

</div>

Im trying to display 2 random images from a directory on my mainpage. I have the files listed in my xml file… images.xml and using the following script pointing to my instance name picture\_mc. all works well for 1 image…how can I get a second image and position it correctly? Do i have to clear the variables? is there an easy way to place the mulitple images into location? Script below…thank you for any help! Please keep explanations simple, I’m very very new at this:

this.\_x = 400; //Offset from top-left corner (0,0)  
this.\_y = -100; //Offset from top-left corner (0,0)

xmlImages = new XML();  
xmlImages.ignoreWhite = true;  
xmlImages.onLoad = loadImages;  
xmlImages.load(“images.xml”);

function loadImages(loaded) {  
if (loaded) {  
xmlFirstChild = this.firstChild;  
imageFileName = [];  
totalImages = xmlFirstChild.childNodes[0].childNodes.length;  
for (i=0; i\<totalImages; i++) {  
imageFileName\* = xmlFirstChild.childNodes[0].childNodes\*.attributes.title;  
}  
randomImage();  
}  
}  
function randomImage() {  
if (loaded == filesize) {  
var ran = Math.round(Math.random() \* (totalImages - 1));  
picture\_mc.loadMovie(imageFileName[ran],1);  
pause();  
}  
}
