Basic preloader question

hi all —

i am currently using this code for my preloader:

myLoaded = Math.round(getBytesLoaded());
myTotal = Math.round(getBytesTotal());
myPercent = myLoaded/myTotal;
myBar._width = myPercent150;
myText = Math.round(myPercent
100)+"%";
if (myLoaded == myTotal) {
gotoAndPlay(3);
} else {
gotoAndPlay(1);
}

where my main movie starts on frame 3.

however, once my movie is uploaded to the web, there is still a blank square where the stage of my .swf will be once it’s loaded, instead of the preloader being there.

the preloader instead, shows up after the entire thing is loaded. is there a way i can make sure that nothing shows except the preloader until all else is loaded?

much MUCH appreciated. thanks.

Load all of your contents into a “container”(blank movie clip) within your preloader and set the visiblity to false until the movie is completely loaded.

on another note,

if (myLoaded == myTotal) {
gotoAndPlay(3);
} else {
gotoAndPlay(1);
}

may be messing your movie up. particularly the gotoAndPlay(1) part i would try ommiting the else half of the expression.

hope this was of some use.
-zac

thanks zac…i will try that

cool man, let me know if you get it working or not, i have a couple more options that may work out for you.

-zac

You don’t need all that rounding at all. Try this:


stop();
function preLoad () {
   var tBytes:Number = _root.getBytesTotal();
   var lBytes:Number = _root.getBytesLoaded();
   var pBytes:Number = Math.round(lBytes/tBytes *100);
   this._width = pBytes;
   _root.text = pBytes + "%";
   if (tBytes == lBytes) {
      _root.gotoAndPlay(3);
   }
};
bar.onEnterFrame = function () {
preLoad();
}

To use that you make you bar a MC with the width you want it to be in the end and place it on the stage with a instance name of “bar”, place a text box on the stage with an instance name of “loaderText”.

actually…do you think you could give me an example code-wise, of how to do that? :slight_smile: