# Swap loader thing

**URL:** <https://forum.kirupa.com/t/swap-loader-thing/47525>\
**Category:** Uncategorized\
**Created:** [April 4, 2004, 8:44pm UTC](https://forum.kirupa.com/t/swap-loader-thing/47525 "2004-04-04T20:44:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik](https://avatars.discourse-cdn.com/v4/letter/q/e19b73/32.png) [@quik](https://forum.kirupa.com/u/quik)\
**Post date:** [April 4, 2004, 8:44pm UTC](https://forum.kirupa.com/t/swap-loader-thing/47525/1 "2004-04-04T20:44:39Z")

</div>

I want to use a next/previous image thing, which loads the next image from an array into a second movieclip(which will be hidden)… then swap the visiblity of mc\_1 and mc\_2 …attach a preloader and stuff.

its basically an effort to save some peoples asses on 56K dial-up lines.

so it alternates between mc\_1 and mc\_2 (which is the easy bit)

```auto

picPath = "";	   
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];

_root.createEmptyMovieClip("myMovieClip", 1);
var mc_1 = _root.myMovieClip.createEmptyMovieClip("imageHolder", 1);
var mc_2 = _root.myMovieClip.createEmptyMovieClip("imageHolder1", 2);
mc_1.picNumber = -1;
mc_2.picNumber = 0;
mc_2._x = 500;

// Load the next image in the array
MovieClip.prototype.loadNextPic = function(i){
    // this gets the next image number, looping around at the end
	this.picNumber = (this.picNumber +i) % _root.pics.length;
	trace(this);
	// load in the image
	this.loadMovie(picPath + _root.pics[this.picNumber]);
	// and start checking to see if it's done loading
}
mc_1.loadNextPic(1);
mc_2.loadNextPic(1);
_root.box.onRelease = function(){
	mc_1.loadNextPic(1);
	mc_2.loadNextPic(1);
};

```

this code works, although when I rerun the function by clicking on “box” it just loads the image at pic[0] (winterrangep1.jpg)  
while tracing this.picNumber in the loadNextNumber function I get NaN.

That only becomes NaN when \_root.box is clicked, not when it is run from the \_root.

I can’t work out why?  
Any ideas? 🙂
