Alright, I’m doing this to make a catalogue better for people on dial-up.
Theres two movie clips, one will be hidden at all times, the next image is loaded into the hidden movieclip.
The next button is working fine, although the previous is not, the objIndex changes down although that array index is not called in loadMovie();
I plan to switch over to colin moocks’ preloader later when I get this working, make it draw/attach a preloader into each movieclip incase the movie has not loaded before the user presses “next”.
Anyway, code is below, looks fine to be but I’ve been looking at it too long.
Any ideas folks?
var objIndex = -1;
picPath = "";
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("image_1", depth++);
_root.holder_mc.createEmptyMovieClip("image_2", depth++);
var mc_1 = _root.holder_mc.image_1;
var mc_2 = _root.holder_mc.image_2;
mc_2._alpha = 0; // set the second to be hidden *IMPORTANT*
mc_2._x = 500; // move it outta the way while testing so I can see whats going on
MovieClip.prototype.loadPic = function(i, action) {
thisObj = this;
objIndex = (objIndex+i)%_root.pics.length;
thisObj.loadMovie(picPath+_root.pics[objIndex]);
if (objIndex<0) {
objIndex += _root.pics.length;
}
};
MovieClip.prototype.swapVis = function(action) {
trace(this._name+": "+action+" objIndex = "+objIndex);
if (this._alpha == 100) {
this._alpha = 0;
if (action == "prev") {
this.loadPic(-1, "prev");
} else if (action == "next") {
this.loadPic(1, "next");
}
} else if (this._alpha == 0) {
this._alpha = 100;
}
};
mc_1.loadPic(1, "next");
mc_2.loadPic(1, "next");
nextButton.onRelease = function() {
mc_1.swapVis("next");
mc_2.swapVis("next");
};
prevButton.onRelease = function() {
mc_1.swapVis("prev");
mc_1.swapVis("prev");
};