# God help the newb - How to add a preloader to this script (External jpegs)

**URL:** <https://forum.kirupa.com/t/god-help-the-newb-how-to-add-a-preloader-to-this-script-external-jpegs/31070>\
**Category:** flash\
**Created:** [September 17, 2003, 11:02pm UTC](https://forum.kirupa.com/t/god-help-the-newb-how-to-add-a-preloader-to-this-script-external-jpegs/31070 "2003-09-17T23:02:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedaykin](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fedaykin](https://forum.kirupa.com/u/fedaykin)\
**Post date:** [September 17, 2003, 11:02pm UTC](https://forum.kirupa.com/t/god-help-the-newb-how-to-add-a-preloader-to-this-script-external-jpegs/31070/1 "2003-09-17T23:02:12Z")

</div>

Hi,

Using this sample script from MM to load external jpeg files. Any suggestions on adding a preloader to it? in between the alpha fades…

//initialize variables and properties  
square.\_alpha = 0;  
whichPic = 1;

//initiate change to new image when buttons are clicked  
next.onPress = function() {  
if (whichPic\<5 && !fadeIn && !fadeOut) {  
fadeOut = true;  
whichpic++;  
input = whichPic;  
}  
};  
back.onPress = function() {  
if (whichPic\>1 && !fadeIn && !fadeOut) {  
fadeOut = true;  
whichpic–;  
input = whichPic;  
}  
};  
\_root.onEnterFrame = function() {  
// when a new Photo is selected, fade out, load new image, and fade in  
if (square.\_alpha\>10 && fadeOut) {  
square.\_alpha -= 10;  
}  
if (square.\_alpha\<10) {  
loadMovie("…/images/image"+whichPic+".jpg", “square”);  
fadeOut = false;  
fadeIn = true;  
}  
if (square.\_alpha\<100 && fadeIn && !fadeOut) {  
square.\_alpha += 10;  
} else {  
fadeIn = false;  
}  
// limit input field  
if (input\>5) {  
input = 5;  
}  
// initiate change to new image when Enter key is pressed  
if (Key.isDown(Key.ENTER)) {  
fadeOut = true;  
whichpic = input;  
}  
};  
// if a number is entered in the input field but Enter is not pressed, change  
// back to current Photo number when clicking anywhere else  
inputField.onKillFocus = function() {  
input = whichPic;  
};
