# Random Image Slideshow

**URL:** https://forum.kirupa.com/t/random-image-slideshow/216353
**Category:** flash
**Created:** [February 15, 2007, 6:55pm UTC](https://forum.kirupa.com/t/random-image-slideshow/216353 "2007-02-15T18:55:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![faubus42](https://avatars.discourse-cdn.com/v4/letter/f/f08c70/32.png) [@faubus42](https://forum.kirupa.com/u/faubus42)
#### Post date: [February 15, 2007, 6:55pm UTC](https://forum.kirupa.com/t/random-image-slideshow/216353/1 "2007-02-15T18:55:09Z")

</div>

Hi all, i’ve been trying to work with this actionscript to make it random and i just can’t seem to do it. Any direction would be greatly appreciated.

```auto

var id, current;
var k = 0, p = 0;
var slide = 1;
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;
        }
        id = setInterval(preloadPic, 100);
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("assets/flash/splash/images.xml");
function Math.preloadPic()(Math.random()*5) {
    clearInterval(id);
    var con = picture.duplicateMovieClip("con"+k, 200+k);
    con.loadMovie(image[p]);
	_root.txt.desc_text_mov.desc_txt.text = description[p];
	
    preloader._visible = 1;

    con._alpha = 0;
    var temp = picture.createEmptyMovieClip("temp"+k, 99+k);
    k++;
    temp.onEnterFrame = function() {
        var total = con.getBytesTotal();
        var loaded = con.getBytesLoaded();
        percent = Math.round(loaded/total*100);
        preloader.preload_bar._xscale = percent;
        if (con._width) {
            preloader._visible = 0;
            con.onEnterFrame = fadeIn;
			_root.txt.gotoAndPlay(2);
            if (slide) {
                id = setInterval(nextImage, 9000);
            }
            delete this.onEnterFrame;
			
        }
    };
}
MovieClip.prototype.fadeIn = function() {
    if (this._alpha<100) {
        current._alpha -= 10;
        this._alpha += 10;
    } else {
        current._visible = 0;
        current = this;
        delete this.onEnterFrame;
    }
};
function nextImage() {
current = this["con"+p];

    p<total-1 ? p++ : p=0;
    preloadPic();
}
function prevImage() {
current = this["con"+p];

    p>0 ? p-- : p=total-1;
	  
    preloadPic();
}
preloadPic();

```
