# Preloading external .jpg

**URL:** <https://forum.kirupa.com/t/preloading-external-jpg/46796>\
**Category:** Uncategorized\
**Created:** [March 28, 2004, 1:28am UTC](https://forum.kirupa.com/t/preloading-external-jpg/46796 "2004-03-28T01:28:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenwhitie](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@jenwhitie](https://forum.kirupa.com/u/jenwhitie)\
**Post date:** [March 28, 2004, 1:28am UTC](https://forum.kirupa.com/t/preloading-external-jpg/46796/1 "2004-03-28T01:28:22Z")

</div>

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&lt;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);
