XML- wait until SWF ends

Hi, I have this code below, what it is trying to do is load a series of swfs in a slideshow automatically, but it needs to wait until the currently loaded swf has stopped playing before it goes on to then next one. I am testing this through checking its currentframe over its totalframes but it doesn’t seem to work that well. Can anyone help?

Thanks!


slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;
// Show the first slide and intialize variables
function startSlideShow(success) {
    if (success == true) {
            rootNode = slides_xml.firstChild;
            totalSlides = rootNode.childNodes.length;
            firstSlideNode = rootNode.firstChild;
            currentSlideNode = firstSlideNode;
            currentIndex = 1;
            updateSlide(firstSlideNode);
    }
}
// Updates the current slide with new image and text 
function updateSlide(newSlideNode) {
    imagePath = newSlideNode.attributes.jpegURL;
    slideText = newSlideNode.firstChild.nodeValue;
    loadMovie(imagePath, targetclip.holder);
}
// Event handler for 'Next slide' button
next_btn.onRelease = function() {
    nextSlideNode = currentSlideNode.nextSibling;
    if (nextSlideNode == null) {
        break;
    } else {
        if(targetclip.holder._currentframe>=targetclip.holder._totalframes){
        currentIndex++;
        updateSlide(nextSlideNode);
        currentSlideNode = nextSlideNode;
    }}
};
// Event handler for 'Previous slide' button
back_btn.onRelease = function() {
    previousSlideNode = currentSlideNode.previousSibling;
    if (previousSlideNode == null) {
        break;
    } else {
        currentIndex--;
        currentSlideNode = previousSlideNode;
        updateSlide(previousSlideNode);
    }
};
loader = function() {
            if(targetclip.holder._currentframe>=targetclip.holder._totalframes){
//
targetclip.movie.gotoAndPlay("in");
//
            nextSlideNode = currentSlideNode.nextSibling;
    if (nextSlideNode == null) {
        break;
    } else {
        currentIndex++;
        updateSlide(nextSlideNode);
        currentSlideNode = nextSlideNode;
            }}
}
setInterval(loader, 1000);