Featured FLA
» Author: Nitin Tikhe
» Title: Cart
» Description: This Animation Tut is a fun and useful for kids below 15 years. Watch the Flag, Doors, Stick and Horse movements.
» More by Nitin Tikhe
Featured Site
» Posted in the Flash Kit Links section
» Title: Banana Swimwear
» Description: This is a banana swim wear interactive catalog we designed and animated in Flash
Most users still have modems so we have to preload the slides to have them ready when buttons are pushed. We make a preload function here
//function to preload slides
function loadAll(firstSlide,lastSlide,slideName,introSlide){
for (j=1;j<=lastSlide;j++) {
//use duplicateMovieClip here instaed of createEmptyMovieClip
duplicateMovieClip (_root.slideHolder, "pic_"+j, j);
//make the slides invisible not to see the loading
setProperty ("pic_"+j, _alpha, (0));
loadMovie(slideName+j+".jpg","pic_"+j);
//load slides into slideholder_1 and make it invisible not to see the loading
loadMovie(slideName+j+".jpg","slideHolder_1");
setProperty("slideHolder_1",_alpha, (0));
//here we load an introduction slide
loadMovie(introSlide,"slideHolder");
}
}
To monitor the loading we attach the following script to slideHolder_1.
onClipEvent(enterFrame){
if(this._url != _root._url && !loaded) {
// calculate size of pics 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.percentOutput = "loading " + percentLoaded + "% of " + kilobytes + "k";
//show text loading slides
_root.loadText.gotoAndPlay("play");
if(percentLoaded == 100){
//loading terminated
loaded = true;
_root.percentOutput = "Ready";
_root.loadText.gotoAndStop("stop");
}
}
}