How to pass variable?

hi, I want to pass a selectedIndex as a variable over to another function so that the loop will follow whatever is being selected in the list.
I’ve tried using return variable;
it doesn’t seem to be working though

I would like to loop the images in the following function by following the ‘count’ variable from the video playback.

for (var q=0; q<total; q++) {

image[q] = xmlNode.childNodes[count].childNodes[1].childNodes[q].firstChild.nodeValue;
image3[q] = xmlNode.childNodes[count].childNodes[2].childNodes[q].firstChild.nodeValue;
messages[q] = xmlNode.childNodes[count].childNodes[3].childNodes[q].firstChild.nodeValue;

}

firstImage();

} else {

content = “file not loaded!”;

}

}

This is the video playback loop. Is it possible to loop the above image slidesshow function using the index of the video? Such as When video 1 is playing, I use the video index of 1 for the image slideshow to know which image it should show.

vidList.complete = function() {
if(seq.selected) {
if(count == list.length-1){
count = 0;

    }
    else {
        count++;

    }

}
else {
    var temp = count;
    while(temp == count) {
    count = Math.floor(Math.random()*list.length);
    }
}
    
vid.play(list.getItemAt(count).data);
list.selectedIndex = count;
list.getSelectedIndex(); 
trace(count);

}

really appreciate any help here. Thank you.

anyone with any ideas?
please help.