# XML Slideshow - delay timer error

**URL:** https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964
**Category:** flash
**Created:** [March 14, 2006, 4:43pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964 "2006-03-14T16:43:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nasdaq404](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nasdaq404](https://forum.kirupa.com/u/nasdaq404)
#### Post date: [March 14, 2006, 4:43pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/1 "2006-03-14T16:43:53Z")

</div>

[FONT=Times New Roman][SIZE=3]There seems to be a time delay problem when the slideshow is playing. It will start playing, but as soon as I click on the next or previous button to view another clip it will mess up the delay time and screw up when the pictures will play. Is there a way on how I can fix this … I attached a link to see what is happening. The following script is what I have playing for the images. What should i do …  
[/SIZE][/FONT][[FONT=Times New Roman][SIZE=3][COLOR=#800080]Slideshow[/COLOR][/SIZE][/FONT]](http://www.strikeya.com/image2.swf)

Here is the fla.

---

<div class="post-metadata">

### Author: ![MattyG](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mattyg/32/868_2.png) [@MattyG](https://forum.kirupa.com/u/MattyG)
#### Post date: [April 6, 2006, 6:31pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/2 "2006-04-06T18:31:42Z")

</div>

Did you have any luck with your problem?

I am having the same issue. Basically… if you hit the next or back buttons a few times the slideshow freaks out and jumps around. It’s like it throws the timing off or something.

Here’s my code yo:

```auto

delay = 10000;
//-----------------------
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        description = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
        prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
        nextImage();
    }
};
Key.addListener(listen);
previous_btn.onRelease = function() {
    prevImage();
};
next_btn.onRelease = function() {
    nextImage();
};
////////////////////////////////////////////////
play_btn._visible = 0;
p = 0;
pause_btn.onRelease = function() {
    clearInterval(myInterval);
    pause_btn._visible = 0;
    play_btn._visible = 100;
};
play_btn.onRelease = function() {
    myInterval = setInterval(pause_slideshow, delay);
    pause_btn._visible = 100;
    play_btn._visible = 0;
};
this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (picture._alpha<100) {
            picture._alpha += 10;
        }
    }
};
function nextImage() {
    pause_btn._visible = 100;
    play_btn._visible = 0;
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p], 1);
            desc_txt.text = description[p];
            picture_num();
            slideshow();
        }
    }
}
function prevImage() {
    pause_btn._visible = 100;
    play_btn._visible = 0;
    if (p>0) {
        p--;
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        desc_txt.text = description[p];
        picture_num();
    }
}
function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0], 1);
        desc_txt.text = description[0];
        picture_num();
        slideshow();
    }
}
function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
    rcaption_btn._visible = 100;
    myInterval = setInterval(pause_slideshow, delay);
}
function pause_slideshow() {
    clearInterval(myInterval);
    if (p == (total-1)) {
        p = 0;
        // firstImage();
    } else if (p == total) {
        gotoAndPlay("credits", 1);
    } else {
        nextImage();
    }
}

```

---

<div class="post-metadata">

### Author: ![MattyG](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mattyg/32/868_2.png) [@MattyG](https://forum.kirupa.com/u/MattyG)
#### Post date: [April 7, 2006, 6:23pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/3 "2006-04-07T18:23:35Z")

</div>

I’m still clueless. I’ve attached my slideshow.

I’ve searched this forum and it seems a lot of people have asked about this with no good solutions.

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 7, 2006, 6:39pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/4 "2006-04-07T18:39:04Z")

</div>

> [@MattyG](#):
>
> I’m still clueless. I’ve attached my slideshow.
> 
> I’ve searched this forum and it seems a lot of people have asked about this with no good solutions.

Try change the slideshow function to

```auto
function slideshow() {
	clearInterval(myInterval)
	rcaption_btn._visible = 100;
	myInterval = setInterval(pause_slideshow, delay);
}

```

---

<div class="post-metadata">

### Author: ![MattyG](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mattyg/32/868_2.png) [@MattyG](https://forum.kirupa.com/u/MattyG)
#### Post date: [April 7, 2006, 6:57pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/5 "2006-04-07T18:57:01Z")

</div>

> [@stringy](#):
>
> Try change the slideshow function to  
> ActionScript Code:  
> [FONT=Courier New][LEFT][COLOR=#000000] **function** [/COLOR] slideshowCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
> &nbsp;&nbsp;&nbsp;&nbsp;clearIntervalCOLOR=#000000[/COLOR]  
> &nbsp;&nbsp;&nbsp;&nbsp;rcaption\_btn.[COLOR=#0000ff]\_visible[/COLOR] = [COLOR=#000080]100[/COLOR];  
> &nbsp;&nbsp;&nbsp;&nbsp;myInterval = [COLOR=#0000ff]setInterval[/COLOR][COLOR=#000000]([/COLOR]pause\_slideshow, delay[COLOR=#000000])[/COLOR];  
> [COLOR=#000000]}[/COLOR]  
> [/LEFT]  
> [/FONT]

Thanks for helping! I still seem to have a problem though… When I start the movie it pauses on the second image. I think it is clearing the interval but then not restarting it maybe???

**EDIT**

I think it’s what I did that is making it not work now. I modified the next & previous functions so that my slideshow would loop and I think that’s what is causing it to hang up. Here’s my code for that:

```auto

function nextImage() {
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p], 1);
            desc_txt.text = description[p];
            picture_num();
        }
    }else{
        p = 0;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p], 1);
            desc_txt.text = description[p];
            picture_num();
        }
    }
}
function prevImage() {
    if (p>0) {
        p--;
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        desc_txt.text = description[p];
        picture_num();
    }else{
        p = total - 1;
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        desc_txt.text = description[p];
        picture_num();
    }    
} 

```

---

<div class="post-metadata">

### Author: ![MattyG](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mattyg/32/868_2.png) [@MattyG](https://forum.kirupa.com/u/MattyG)
#### Post date: [April 7, 2006, 7:10pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/6 "2006-04-07T19:10:29Z")

</div>

OK, nevermind my last post. Got it…

Thanks again!

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 7, 2006, 7:36pm UTC](https://forum.kirupa.com/t/xml-slideshow-delay-timer-error/181964/7 "2006-04-07T19:36:00Z")

</div>

> [@MattyG](#):
>
> OK, nevermind my last post. Got it…
> 
> Thanks again!

welcome
