# Slideshow jumping/skipping

**URL:** <https://forum.kirupa.com/t/slideshow-jumping-skipping/321617>\
**Category:** flash\
**Created:** [April 26, 2011, 4:50am UTC](https://forum.kirupa.com/t/slideshow-jumping-skipping/321617 "2011-04-26T04:50:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![edesigns](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@edesigns](https://forum.kirupa.com/u/edesigns)\
**Post date:** [April 26, 2011, 4:50am UTC](https://forum.kirupa.com/t/slideshow-jumping-skipping/321617/1 "2011-04-26T04:50:39Z")

</div>

Flash CS5, AS2.0

I have been using Kirupa’s tutorials to create a gallery slideshow with next, previous, play, & pause buttons as well as thumbnails. It seems to work fine at first but after awhile or after loading several different galleries in the root loader mc, it starts to jump around or skip through 3 or 5 images at a time. Each gallery contains the same code that is below.

```auto
delay = 4000;

onEnterFrame = function(){
	clearInterval(myInterval);
}

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		thumbnails = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
			thumbnails_fn(i);
		}
		firstImage();
	} else {
		content = "file not loaded!";
	}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("galleryone.xml");
///////////////////////////////////// 

previous_btn.onRelease = function() {
	
	prevImage();
	playing = false
	clearInterval(myInterval)
	
	VarX = getProperty ( play_btn, _visible );
if (VarX == false) {
setProperty ("play_btn", _visible, true);
}
VarY = getProperty ( stop_btn, _visible );
if (VarY == true) {
	setProperty ("stop_btn", _visible, false);
}
	
};
next_btn.onRelease = function() {
	
	nextImage();
	playing = false
	clearInterval(myInterval)
	
	VarX = getProperty ( play_btn, _visible );
if (VarX == false) {
setProperty ("play_btn", _visible, true);
}
VarY = getProperty ( stop_btn, _visible );
if (VarY == true) {
	setProperty ("stop_btn", _visible, false);
}
	
};
///////////////////////////////////// 
p = 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;
		}
	}
};
var myInterval;
function nextImage() {
	p++;
	p %= image.length;
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[p], 1);
		clearInterval(myInterval);
		if (playing) {
			slideshow();
		}
	}
}
function prevImage() {
	clearInterval(myInterval);
	if (playing) {
		slideshow();
	}
	if (p>0) {
		p--;
	} else {
		p = image.length-1;
	}
	picture._alpha = 0;
	picture.loadMovie(image[p], 1);
}
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		clearInterval(myInterval);
		if (playing) {
			slideshow();
		}
	}
}

setProperty(play_btn, _visible, false);

function slideshow() {
	myInterval = setInterval(pause_slideshow, delay);
	function pause_slideshow() {
		clearInterval(myInterval);
		nextImage();
	}
}
playing = true

play_btn.onPress = function(){
	playing = true
	nextImage()
	
	
	
}

stop_btn.onPress = function(){
	playing = false
	clearInterval(myInterval)
}
setProperty(thumbnail_mc, _visible, false);

function thumbNailScroller() {
	this.createEmptyMovieClip("tscroller", 1000);
	scroll_speed = 10;
	tscroller.onEnterFrame = function() {
		if ((_ymouse>=thumbnail_mc._y) && (_ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
			if ((_xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
				thumbnail_mc._x -= scroll_speed;
			} else if ((_xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
				thumbnail_mc._x += scroll_speed;
			}
		} else {
			delete tscroller.onEnterFrame;
		}
	};
}

function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {

target_mc._x = size;
size = hit_left._x+(target_mc._width+5) + target_mc._x;

target_mc.pictureValue = k;
target_mc.onRelease = function() {

VarX = getProperty ( play_btn, _visible );
if (VarX == false) {
setProperty ("play_btn", _visible, true);
}
VarY = getProperty ( stop_btn, _visible );
if (VarY == true) {
	setProperty ("stop_btn", _visible, false);
}

	
p = this.pictureValue-1;
playing = false
clearInterval(myInterval)
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
stop();

```

Can anyone help me? I’ve been beating my head against a wall for the past three days. Suggestions?

Thanks ahead of time!

* * *

Also, if anyone can tell why the thumbnails don’t load in order…
