Image gallery - random array

hey all,

I found this code online. it is for a image gallery that fades in and out as it transition from one image to the next… the images are load through an array command… it loads the first image, etc… what I wanted to know is where should i put a Math.floor(Math.random()*this.pic_arr.length); in the string of code… to make the gallery start randomly in the array and then continue onto the next image… also, for some reason, there is not a common directory for all the images, like this script:

this.pathToPics = “bannerimage/”;
this.pArray = [“pic2.jpg”,“pic3.jpg”,“pic4.jpg”,“pic5.jpg”];
this.pIndex = Math.floor(Math.random()*this.pArray.length);
loadMovie(this.pathToPics+this.pArray[this.pIndex], this.menu.photo);

“bannerimage” is the common directory…

here is the code from the tutorial… if someone could help me with these two problems, that would be great…

here is the code in the main stage…

pic_arr = [“flower_pink.jpg”, “flower_yellow.jpg”, “flower_purple.jpg”, “flower_red.jpg”, “flower_orange.jpg”];
color_arr = [0xf75eb0, 0xf6f818, 0xbb57c8, 0xdf1734, 0xfe9809];

blank_mc.attachMovie(“slideshow”, “uuShow”, 1, {
_x:0, _y:0, _visible:false, fps:12, nFrames:24, alphaIncr:10,
slides_arr:pic_arr, slideDepth:50, repeat:true});

blank_mc.uuShow.addListener(blank_mc);

blank_mc.onSlideLoaded = function(i) {
(new Color(this._parent[“dot”+i+"_mc"])).setRGB(color_arr*);
};

blank_mc.onAllSlidesLoaded = function() {
this.uuShow._visible = true;
this.uuShow.beginTransitions();
};

blank_mc.onShowOver = function() {
//set repeat:false in uuShow for this to be called
//trace(‘slideshow is over’);
};

code found in the slideshow component

#initclip 1
Slideshow = function() {
ASBroadcaster.initialize(this);
this.loadInSeq(0);
}

Slideshow.prototype = new MovieClip ();

Slideshow.prototype.loadInSeq = function(i) {
var slide = this.createEmptyMovieClip(“slide” + i, this.slideDepth++);
// hide all slides loading on top of first one
if (i > 0) slide._alpha = 0;
slide.loadMovie(this.slides_arr*);
checkLoadedID = setInterval(function(i, mc) {
if (mc[“slide” + i]._width > 0) {
mc[“slide” + i]._visible = true;
mc.broadcastMessage(“onSlideLoaded”, i);
clearInterval(checkLoadedID);
// start next one loading (if not last)
if (i < mc.slides_arr.length-1) {
mc.loadInSeq(i + 1);
} else {
mc.broadcastMessage(“onAllSlidesLoaded”);
}
}
}, 1000/this.fps, i, this);

};

Slideshow.prototype.beginTransitions = function() {
var holdTimeMs = 1000 * this.nFrames / this.fps;
holdID = setInterval(function(mc) { mc.activateInSeq(0); clearInterval(holdID); }, holdTimeMs, this);
};

Slideshow.prototype.activateInSeq = function(i) {
if (++i < this.slides_arr.length) {
this[“slide” + i]._alpha = 0;
this[“slide” + i].swapDepths(this.slideDepth++);
this.onEnterFrame = function() {
if (this[“slide” + i]._alpha >= 95) {
var counter = this.nFrames;
this.onEnterFrame = function() {
if (!counter–) {
delete this.onEnterFrame;
this.activateInSeq(i);
}
};
} else {
this[“slide” + i]._alpha += this.alphaIncr;
}
};
} else {
if (this.repeat) this.activateInSeq(-1);
else this.broadcastMessage(“onShowOver”);
}
};

Object.registerClass(“slideshow”, Slideshow);
#endinitclip