Randomness hopelessness

I have a AS2 slideshow that plays through a few dynamic (XML) images, but I would like to randomize which image is being displayed…

I have searched the forums looking for how to do this but I cant get anything workin…

Any help is appreciated

cheers,
:thumb2:

here is all the code:

 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#808080]*#include "lmc_tween.as"*[/COLOR]

[COLOR=#808080]//********************************[/COLOR]

[COLOR=#808080]// baseurl to use to locate images based on SWF url not HTML url[/COLOR]
[COLOR=#808080]//var baseurl = _url.substr(0,_url.lastIndexOf("/")+1);[/COLOR]

[COLOR=#808080]// create and position empty clips for images[/COLOR]
[COLOR=#808080]// one for visible image, one which will be [/COLOR]
[COLOR=#808080]
// used for preloading the next image
[/COLOR]
[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]// on top[/COLOR]
[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR]COLOR=#000000[/COLOR];
one.[COLOR=#0000ff]_x[/COLOR] = two.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#000080]0[/COLOR];
one.[COLOR=#0000ff]_y[/COLOR] = two.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#000080]30[/COLOR];

[COLOR=#808080]// clips represents the clips with images[/COLOR]
clips = [COLOR=#000000][[/COLOR]one,two[COLOR=#000000]][/COLOR];
timeline = [COLOR=#0000ff]this[/COLOR]; [COLOR=#808080]// allows reference to timeline from other clips[/COLOR]
[COLOR=#808080]// images is an array of the names of the images being used[/COLOR]
[COLOR=#808080]// this is for file referencing as well as status display[/COLOR]
[COLOR=#000000]function[/COLOR] loadXMLCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]xmlNode[/COLOR] = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]firstChild[/COLOR];
images = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
description = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
total = [COLOR=#0000ff]xmlNode[/COLOR].[COLOR=#0000ff]childNodes[/COLOR].[COLOR=#0000ff]length[/COLOR];
[COLOR=#0000ff]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i<total; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
images[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#0000ff]xmlNode[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]nodeValue[/COLOR];
description[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#0000ff]xmlNode[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]nodeValue[/COLOR];

    [COLOR=#000000]}[/COLOR]
    status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"xml is loaded!"[/COLOR];
    FirstLoad[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#808080]*//PreloadNext();*[/COLOR]
    [COLOR=#808080]*//next_one();*[/COLOR]
    
[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]
    status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"file not loaded!"[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]
xmlData = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]XML[/COLOR]COLOR=#000000[/COLOR];
xmlData.[COLOR=#0000ff]ignoreWhite[/COLOR] = [COLOR=#000000]true[/COLOR];
xmlData.[COLOR=#0000ff]onLoad[/COLOR] = loadXML;
xmlData.[COLOR=#0000ff]load[/COLOR]COLOR=#000000[/COLOR];

[COLOR=#000000]function[/COLOR] GetFileForCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]return[/COLOR] +[COLOR=#0000ff]name[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]// Preload checks to see if a clip has been loaded[/COLOR]
[COLOR=#000000]function[/COLOR] PreloadCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] lod = clip.[COLOR=#0000ff]getBytesLoaded[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] tot = clip.[COLOR=#0000ff]getBytesTotal[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]lod && tot[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] percent_loaded = lod/tot;
progress_mc.[COLOR=#0000ff]_xscale[/COLOR] = [COLOR=#000080]100[/COLOR]* percent_loaded;
[COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]lod == tot[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"Preloading complete for "[/COLOR]+images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];
[COLOR=#0000ff]return[/COLOR] [COLOR=#000000]true[/COLOR]; [COLOR=#808080]// is complete[/COLOR]
[COLOR=#808080]//progress_mc._visible = false;[/COLOR]

    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#0000ff]return[/COLOR] [COLOR=#000000]**false**[/COLOR]; [COLOR=#808080]*// is not complete*[/COLOR]

[COLOR=#000000]}[/COLOR]

[COLOR=#808080]// PreloadNext is used as an onEnterFrame event[/COLOR]
[COLOR=#808080]// to check the loading of the current image and [/COLOR]
[COLOR=#808080]
// reorders the arrays so that the first element
[/COLOR]
[COLOR=#808080]// now represents the next image/clip[/COLOR]
[COLOR=#000000]function[/COLOR] PreloadNextCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] is_complete = PreloadCOLOR=#000000[/COLOR];
[COLOR=#808080]//progress_mc._visible = true;[/COLOR]
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
clips.[COLOR=#0000ff]push[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]// shift order of arrays[/COLOR]
images.[COLOR=#0000ff]push[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#808080]//Pauser();[/COLOR]
[COLOR=#0000ff]delete[/COLOR] [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]onEnterFrame[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]// initiate loading of first image[/COLOR]
clips[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]loadMovie[/COLOR]COLOR=#000000[/COLOR];
status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"Preloading "[/COLOR]+images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];
[COLOR=#808080]//black.swapDepths(100);[/COLOR]

[COLOR=#808080]// FirstLoad is like PreloadNext but loads the first image[/COLOR]
[COLOR=#808080]// adding in a status message otherwise handled by the next button[/COLOR]
[COLOR=#808080]// and starting the second image to load when complete.[/COLOR]
[COLOR=#000000]function[/COLOR] FirstLoadCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] is_complete = PreloadCOLOR=#000000[/COLOR];
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
clips.[COLOR=#0000ff]push[/COLOR]COLOR=#000000[/COLOR];
images.[COLOR=#0000ff]push[/COLOR]COLOR=#000000[/COLOR];
clips[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]loadMovie[/COLOR]COLOR=#000000[/COLOR];
status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"Preloading "[/COLOR]+images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];
timeline.[COLOR=#0000ff]onEnterFrame[/COLOR] = PreloadNext;
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]//calls a function called GoBack every 4 seconds//[/COLOR]

[COLOR=#808080]// next_btn.onPress shows the next image if preloaded and starts[/COLOR]
[COLOR=#808080]// preloading the next one using PreloadNext as an onEnterFrame event[/COLOR]
next_one = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]“Please wait for “[/COLOR]+images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR]+[COLOR=#ff0000]” to complete”[/COLOR];

[COLOR=#000000]}[/COLOR]
[COLOR=#808080]*//clips[0]._alpha = 100;*[/COLOR]
[COLOR=#808080]*//clips[1]._alpha = 0;*[/COLOR]

clips[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]swapDepths[/COLOR][COLOR=#000000]([/COLOR]clips[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR]; [COLOR=#808080]*// move preloaded image to top*[/COLOR]
clips[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]_alpha[/COLOR] = [COLOR=#000080]0[/COLOR];

clips[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]loadMovie[/COLOR][COLOR=#000000]([/COLOR]images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];

status_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"Preloading "[/COLOR]+images[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];
timeline.[COLOR=#0000ff]onEnterFrame[/COLOR] = PreloadNext;
clips[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#000080]alphaTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]100[/COLOR],[COLOR=#000080]3[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]*//clips[0].alphaTo(100,1,1);*[/COLOR]

[COLOR=#000000]}[/COLOR]
[COLOR=#0000ff]stop[/COLOR]COLOR=#000000[/COLOR];

Pauser = [COLOR=#0000ff]setInterval[/COLOR][COLOR=#000000]([/COLOR]GoNext, [COLOR=#000080]3000[/COLOR][COLOR=#000000])[/COLOR]

[COLOR=#000000]function[/COLOR] GoNextCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]timeline.[COLOR=#000080]progress_mc[/COLOR].[COLOR=#0000ff]_xscale[/COLOR] == [COLOR=#000080]100[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#808080]//clips[1].alphaTo(0,2);[/COLOR]
next_oneCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]