Hello, I followed the tutorial for making a slide show that loades external .jpgs fades them in and then transitions nicely to the next. I posted it on the web, and on a fast connection the slides load really nicely and look smooth. On a slow connection, the images never appear because the file doesn’t have time to load before it is told to go on to the next image.
So, is there a way to preload the external .jpg’s?
Here is my code. If anyone has any ideas about how to make this happen on a slow connection please let me know.
thanks!
this.pathToPics = “slides/”;
this.pArray = [“slide_1.jpg”, “slide_2.jpg”, “slide_3.jpg”, “slide_4.jpg”, “slide_5.jpg”, “slide_6.jpg”, “slide_7.jpg”, “slide_8.jpg”, “slide_9.jpg”, “slide_10.jpg”, “slide_11.jpg”, “slide_12.jpg”, “slide_13.jpg”, “slide_14.jpg”, “slide_15.jpg”, “slide_16.jpg”, “slide_17.jpg”];
this.fadeSpeed = 5;
this.pIndex = 0;
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
MovieClip.prototype.changePhoto = function(d) {
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
var p = _root.photo;
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
aChange = function(i) {
i.changePhoto(1);
};
setInterval(aChange, 6000, this);