Hi everybody, I have created a preloader, but when I open the movie online. the preloader doesn’t show until the loading bar is at 50% at least.
Is there any reason for this to happens? I would like it to show up from 0%.
Here is the code:
//this is first frame of the movie
stop();
//this is to load a background image randomly
var randomNumber:Number = 1 + random(5);
var randomBackground:String = “background_images/background” + randomNumber.toString() + “.jpg”;
background_mc.createEmptyMovieClip(“imageHolder_mc”, 1);
background_mc.imageHolder_mc.loadMovie(randomBackground);
background_mc._visible = false;
//SCRIPT FOR THE PRELOADER
this.onEnterFrame = function() {
loadedB = background_mc.imageHolder_mc.getBytesLoaded();
totalB = background_mc.imageHolder_mc.getBytesTotal();
totalBytes = this.getBytesTotal() + this.totalB;
loadedBytes = this.getBytesLoaded() + this.loadedB;
if (loadedBytes != totalBytes) {
this.preloader_mc.title_txt.text=“LOADING INTERFACE”
percent = Math.floor(100 * loadedBytes / totalBytes);
this.preloader_mc.preloaderBar_mc._xscale = percent;
this.preloader_mc.percent_txt.text = percent + “%”;
} else {
_root.background_mc._visible = true;
_root.createEmptyMovieClip(“transition”, 2);
_root.transition.attachMovie(“cojones”, “cojones2”, 3);
background_mc.setMask(_root.transition);
this.preloader_mc._alpha -= 10;
if (this.preloader_mc._alpha <= 0) {
delete this.onEnterFrame;
_root.gotoAndStop(“InitialAnimation”);
}
}
};