Introduction
This is a tutorial for a simple slide show to start with. In this slide show only the next picture is preloaded while the user looks at a slide. This avoids unnecessary loading of many pics.
This first function will load the pics and thumbs into the corresponding positions. bilder_2 is the movieclip, which holds the preloaded pic.
//load pics
stop();
function loadImage(img,nextImg,viewNext,viewPrev){
backLoader.loadMovie(viewNext);
forwardLoader.loadMovie(viewPrev)
bilder_1.loadMovie(img);
bilder_2.loadMovie(nextImg);
bilder_2._alpha = 0;
}
loadImage("nail_1.jpg","nail_2.jpg","pic_2b.jpg","pic_1b.jpg");
This is a function of the movieclip holding the main pic to center the pic within the movie.
onClipEvent (enterFrame) {
this._x = (450-this._width)/2;
//450 is the height and width of movie
//this will center the pic in the movie
this._y = (450-this._height)/2;
}
This function is for the preloader movieclip to monitor the loading of the pic.
onClipEvent (enterFrame) {
if(this._url != _root._url && !loaded) {
// calculate size of SWF in kilobytes
var kilobytes = Math.ceil(this.getBytesTotal()/1024);
// calculate percent loaded
var percentLoaded = Math.ceil((this.getBytesLoaded()/this.getBytesTotal()) * 100);
// show loading message
_root.clipladen.totalBox.text = kilobytes + "kb";
_root.clipladen.loadBox.text = percentLoaded + "%";
if(percentLoaded >= 100){
loaded = true; //terminate loop
_root.clipladen.readyBox.text = "Ready";
}
}
}