# NEWBIE: Preloader doesn't load into cache! Help

**URL:** <https://forum.kirupa.com/t/newbie-preloader-doesnt-load-into-cache-help/60673>\
**Category:** Uncategorized\
**Created:** [August 11, 2004, 2:58pm UTC](https://forum.kirupa.com/t/newbie-preloader-doesnt-load-into-cache-help/60673 "2004-08-11T14:58:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spiro9210](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@spiro9210](https://forum.kirupa.com/u/spiro9210)\
**Post date:** [August 11, 2004, 2:58pm UTC](https://forum.kirupa.com/t/newbie-preloader-doesnt-load-into-cache-help/60673/1 "2004-08-11T14:58:28Z")

</div>

I have a little problem, I have been trying to load a .swf movie into my flash movie. Unfortunately, this movie is too large; therefore, I used a preloader. I tried this preloader below (I inserted a “gotoAndPlay(1);” on frame 2 and named frame 3 “start”)—\>

```auto
totalBytes = Math.round(getBytesTotal()/1024);
loadedBytes = Math.round(getBytesLoaded()/1024);
percentDone = Math.round((loadedBytes/totalBytes)*100);
if (_root._framesloaded>=_root._totalframes) {
gotoAndPlay("start");
}

```

This code above works alone with the movie, and it **does** cache, but when the movie is loaded into another flash movie, the code doesn’t work. The entire movie just loads before anything shows up. I even tried changing “\_root.” to Parent. It didn’t help either. Anyway, I discarded the code and tried the one below (I found on this website)—\>

```auto
stop()
bar._width = 0
assessLoad = function (clip) {
var kbLoaded = Math.floor(clip.getBytesLoaded()/1024);
var kbTotal = Math.floor(clip.getBytesTotal()/1024);
percent = kbLoaded/kbTotal;
bar._xscale =percent*100
percent_txt.text = Math.floor(percent*100)+"%";
if ((kbLoaded == kbTotal) && kbTotal>1) {
clip.gotoAndStop(2)
clearInterval(myInterval);
}
};
myInterval = setInterval(assessload,50,this)

```

This second code works like a charm. It’s very user friendly. It works by using only frame 1 for the preloading sequence. The .swf movie preloaded and loaded in my flash movie just fine, but whenever I hit the button, it goes through the preloading sequence every time. I checked my cache, and It didn’t show up. Is there a way to make the second code above allow caching.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2004, 11:45pm UTC](https://forum.kirupa.com/t/newbie-preloader-doesnt-load-into-cache-help/60673/2 "2004-08-11T23:45:19Z")

</div>

Interesting problem. Does this happen using all browsers?

For what reason have included && kbTotal \> 1? Perhaps there is a nice reason but as far s I would tell you, you don’t need it. if(kbLoaded == kbTotal) should work fine, but you might want to see what happens by reversing the if statement to say  
[AS]  
if(kbLoaded != kbTotal){  
assessLoad(this);  
}else{  
this.play();  
}  
[/AS]  
C

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 12, 2004, 5:21am UTC](https://forum.kirupa.com/t/newbie-preloader-doesnt-load-into-cache-help/60673/3 "2004-08-12T05:21:57Z")

</div>

> [@Carixpig](#):
>
> Interesting problem. Does this happen using all browsers?
> 
> For what reason have included && kbTotal \> 1? Perhaps there is a nice reason but as far s I would tell you, you don’t need it. if(kbLoaded == kbTotal) should work fine, but you might want to see what happens by reversing the if statement to say  
> [AS]  
> if(kbLoaded != kbTotal){  
> assessLoad(this);  
> }else{  
> this.play();  
> }  
> [/AS]  
> C

Well, I give a try and see. Thanks
