Search Tutorials
PreloaderFinally, I would like to present a preloader, which I made especially for files with components but of course can be used for anything. Components are loaded prior to anything else. If you use the usual preloader and your file has many components you would notice that for sometimes your preloader does not appear untill all the components are loaded. If the separate the preloader from the actual movie, this does not happen. This is the script in frame 1. stop();
//check the "preloader" MC for a script.
//we make the loaderbar at the beginning invisible,
//because it will show up before the movie is loaded.
_root.loaderBar._visible = false;
_root.preHolder.loadMovie("advanced_search.swf");
We make our loaderBar invisible, because otherwise it will show up and start, even no loading occurs and then when loading it will start again. Inside of the empty movieclip preHolder we have the following code:
onClipEvent(enterFrame){
if(this._url != _root._url && !this._url.loaded) {
var kilobytes = Math.ceil(this.getBytesTotal()/1024);
_root.frame = Math.ceil((this.getBytesLoaded()/this.getBytesTotal())*100);
_root.loaderBar.gotoAndPlay (_root.frame);
_root.frame = "loading " + _root.frame + "% of " + kilobytes + "kb";
_root.loaderBar._visible = true;
if(this.getBytesLoaded() == this.getBytesTotal()){
this._url.loaded = true;
_root.gotoAndStop("start");
}
}
}
This is one of those typical loaderscripts, which I mixed together from other scripts, but it works and that is important. Important also that here we make the loaderbar visible again for loading. Finally we have a second frame with this code:
stop();And that is it, ready to go.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|