# Starting with Random Image: Photo Slideshow Using XML and Flash

**URL:** https://forum.kirupa.com/t/starting-with-random-image-photo-slideshow-using-xml-and-flash/234779
**Category:** Uncategorized
**Created:** [August 6, 2007, 3:27am UTC](https://forum.kirupa.com/t/starting-with-random-image-photo-slideshow-using-xml-and-flash/234779 "2007-08-06T03:27:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![histwinsister](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/histwinsister/32/380_2.png) [@histwinsister](https://forum.kirupa.com/u/histwinsister)
#### Post date: [August 6, 2007, 3:27am UTC](https://forum.kirupa.com/t/starting-with-random-image-photo-slideshow-using-xml-and-flash/234779/1 "2007-08-06T03:27:17Z")

</div>

i want to strip this down and remove the image counter, description and buttons… which is easy enough.

but i would also like the starting image to be random. i mean, the first image that is loaded is selected randomly from the xml file.

can anyone help me with the real quick? here is the AS

delay = 6000;  
//-----------------------  
function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;  
image = [];  
description = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {

image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;

}  
firstImage();

} else {

content = “file not loaded!”;

}

}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);

p = 0;  
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {

preloader.preload\_bar.\_xscale = 100\*loaded/filesize;

} else {

preloader.\_visible = false;  
if (picture.\_alpha\<100) {

picture.\_alpha += 10;

}

}

};  
function nextImage() {

if (p\<(total-1)) {

p++;  
if (loaded == filesize) {

picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
slideshow();

}

}

}  
function prevImage() {

if (p\>0) {

p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();

}

}  
function firstImage() {

if (loaded == filesize) {

picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
picture\_num();  
slideshow();

}

}  
function picture\_num() {

current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;

}  
function slideshow() {

myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {

clearInterval(myInterval);  
if (p == (total-1)) {

p = 0;  
firstImage();

} else {

nextImage();

}

}

}
