# Xml slideshow: how to add pause functionality

**URL:** <https://forum.kirupa.com/t/xml-slideshow-how-to-add-pause-functionality/226965>\
**Category:** Uncategorized\
**Created:** [May 25, 2007, 1:20pm UTC](https://forum.kirupa.com/t/xml-slideshow-how-to-add-pause-functionality/226965 "2007-05-25T13:20:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bltaug3](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@bltaug3](https://forum.kirupa.com/u/bltaug3)\
**Post date:** [May 25, 2007, 1:20pm UTC](https://forum.kirupa.com/t/xml-slideshow-how-to-add-pause-functionality/226965/1 "2007-05-25T13:20:30Z")

</div>

I have been working on an xml based flash slideshow (with much help from the [tutorial)](http://www.kirupa.com/developer/mx2004/xml_slideshow.htm)  
However, I am now running into some problems as I try to create a pause button. Is it possible to pause/continue the slideshow? the main functionality code for the slideshow is below:

```auto
delay = 5000;
//----------------------- 
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        header = [];
        author = [];
        caption = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            header* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            author* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            caption* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("photo_essay.xml");

/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
    filesize = image_mc.imageLoader.getBytesTotal();
    loaded = image_mc.imageLoader.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (image_mc.imageLoader._alpha<100) {
            //TRANSITION SPEED (IMAGE)
            image_mc.imageLoader._alpha += 6;
        }
    }
};
function nextImage() {
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            image_mc.imageLoader._alpha = 0;
            image_mc.imageLoader.loadMovie(image[p], 1);
            articleHeader.text = header[p];
            articleAuthor.text = author[p];
            this.caption_mc.caption_holder.captions.text = caption[p];
            picture_num();
            slideshow();
            slide();
        }
    }
}
function prevImage() {
    if (p>0) {
        p--;
        image_mc.imageLoader._alpha = 0;
        image_mc.imageLoader.loadMovie(image[p], 1);
        articleHeader.text = header[p];
        articleAuthor.text = author[p];
        this.caption_mc.caption_holder.captions.text = caption[p];
        picture_num();
        slide();
    }
}
function firstImage() {
    if (loaded == filesize) {
        image_mc.imageLoader._alpha = 0;
        image_mc.imageLoader.loadMovie(image[0], 1);
        articleHeader.text = header[0];
        articleAuthor.text = author[0];
        this.caption_mc.caption_holder.captions.text = caption[0];
        picture_num();
        slideshow();
        slide();
    }
}
function picture_num() {
    current_pos = p+1;
    counter.text = current_pos+" / "+total;
}
function slide() {
    this.mc_mask.gotoAndPlay(2);
    this.caption_mc.gotoAndPlay(2);
}
function slideshow() {
    myInterval = setInterval(pause_slideshow, delay);
    function pause_slideshow() {
        clearInterval(myInterval);
        if (p == (total-1)) {
            p = 0;
            firstImage();
        } else {
            nextImage();
        }
    }
}

```
