The random image thread

alright i looked around the site and i couldnt find an answer to this question, so here goes…

I have managed to make a function that calls a random image, however i am unable to call the Correct description and picture number (’ p ')…i know why this is but i am clueless on how to go about fixing it…

thanks for any help…

p=0;
function randomimg() {
if (loaded == filesize) {
if (p<(total-1)) {
p++;
myNumber = Math.floor(Math.random()*image.length);
picture.loadMovie(image[myNumber]);
desc_txt.text = description[p];
picture_num();
picture._alpha = 0;
}
}
}

function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}