# Basic preloader question

**URL:** <https://forum.kirupa.com/t/basic-preloader-question/185356>\
**Category:** Uncategorized\
**Created:** [April 12, 2006, 6:19pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356 "2006-04-12T18:19:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkatcher](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jkatcher](https://forum.kirupa.com/u/jkatcher)\
**Post date:** [April 12, 2006, 6:19pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/1 "2006-04-12T18:19:15Z")

</div>

hi all —

i am currently using this code for my preloader:

myLoaded = Math.round(getBytesLoaded());  
myTotal = Math.round(getBytesTotal());  
myPercent = myLoaded/myTotal;  
myBar.\_width = myPercent_150;  
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.

---

<div class="post-metadata">

**Author:** ![zbra55](https://avatars.discourse-cdn.com/v4/letter/z/ecd19e/32.png) [@zbra55](https://forum.kirupa.com/u/zbra55)\
**Post date:** [April 12, 2006, 6:39pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/2 "2006-04-12T18:39:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jkatcher](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jkatcher](https://forum.kirupa.com/u/jkatcher)\
**Post date:** [April 12, 2006, 6:44pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/3 "2006-04-12T18:44:36Z")

</div>

thanks zac…i will try that

> [@zbra55](#):
>
> 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,
> 
> 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

---

<div class="post-metadata">

**Author:** ![zbra55](https://avatars.discourse-cdn.com/v4/letter/z/ecd19e/32.png) [@zbra55](https://forum.kirupa.com/u/zbra55)\
**Post date:** [April 12, 2006, 6:54pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/4 "2006-04-12T18:54:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thinker2501](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thinker2501](https://forum.kirupa.com/u/Thinker2501)\
**Post date:** [April 12, 2006, 9:28pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/5 "2006-04-12T21:28:13Z")

</div>

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

```auto

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”.

---

<div class="post-metadata">

**Author:** ![jkatcher](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jkatcher](https://forum.kirupa.com/u/jkatcher)\
**Post date:** [April 12, 2006, 10:29pm UTC](https://forum.kirupa.com/t/basic-preloader-question/185356/6 "2006-04-12T22:29:04Z")

</div>

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

> [@zbra55](#):
>
> 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
