# Preloader and external SWF---not clear on how

**URL:** <https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857>\
**Category:** flash\
**Created:** [September 20, 2004, 8:49pm UTC](https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857 "2004-09-20T20:49:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cameramano](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cameramano](https://forum.kirupa.com/u/cameramano)\
**Post date:** [September 20, 2004, 8:49pm UTC](https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857/1 "2004-09-20T20:49:46Z")

</div>

Ok… so I’ve spent the day trying to figure out how to get my preloader to work on external SWF’s. I can’t put the preloader on the SWF because I want to make a “generic” preloader that is easy for my co-workers to use. Having read several, several threads, I tried putting the SWF in a level, then refering the preloader to that level. No luck there. The preloader won’t sense it… or maybe the movie won’t go back to the preloader… I don’t know.

Frame 1:  
onClipEvent (load){  
totalwidth = getProperty(\_root.loadbar,\_width);  
widthfactor=(totalwidth/100);  
}  
onClipEvent (enterFrame){  
var total= level10.getBytesTotal();  
var loadedup= level10.getBytesLoaded();  
trace (total);  
if (loadedup==total){  
\_root.gotoAndPlay(2);  
}else{  
gotoAndStop(1);  
percent=Math.round ((loadedup/total)_100);  
\_root.loadbar.\_width=(widthfactor_percent);  
output\_txt=“loading(” + percent + “%” + “)”;  
}  
}

Frame 2:

stop();  
loadMovieNum (“GenInfoGame2.swf”,10);

The movie loads fine (just no preloader).  
The preloader works fine with the appropriate modifications for a normal image on frame 2.

I know the problem is with references… but I don’t know how to fix it. Anyone out there (Lunatic???) 😉

---

<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:** [September 20, 2004, 9:56pm UTC](https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857/2 "2004-09-20T21:56:11Z")

</div>

> onClipEvent (load){  
> totalwidth = getProperty(\_root.loadbar,\_width);  
> widthfactor=(totalwidth/100);  
> }  
> onClipEvent (enterFrame){  
> var total= level10.getBytesTotal();  
> var loadedup= level10.getBytesLoaded();  
> trace (total);  
> if (loadedup==total){  
> \_root.gotoAndPlay(2);  
> }else{  
> gotoAndStop(1);  
> percent=Math.round ((loadedup/total)_100);  
> \_root.loadbar.\_width=(widthfactor_percent);  
> output\_txt=“loading(” + percent + “%” + “)”;  
> }  
> }

you have this on as frame action?  
clip events are specific to movie clips.  
What I’d do is have an empty mc sitting on-stage with the above script on it. On the first frame, have your load movie script and a stop.

The way this was set up, you were asking it to get the total amount of bytes from a level that was empty.

here’s the way i’d do it:  
on the empty MC:

```auto
onClipEvent (load){
  totalwidth = getProperty(_root.loadbar._width);
  widthfactor=(totalwidth/100);
 }
 onClipEvent (enterFrame){
  var total= level10.getBytesTotal();
  var loadedup= level10.getBytesLoaded();
  trace (total);
   percent=Math.round ((loadedup/total)*100);
   _root.loadbar._width=(widthfactor*percent);
   output_txt="loading(" + percent + "%" + ")";
       if (loadedup==total){
        _level10.gotoAndPlay(2);
       }else{
        _level10.Stop();
     }
 }

```

frame 1 action:

```auto
 stop();
 loadMovieNum ("GenInfoGame2.swf",10);
  

```

---

<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:** [September 21, 2004, 12:36pm UTC](https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857/3 "2004-09-21T12:36:41Z")

</div>

Thanks for the advice. I’m not sure I understand, though. If I put the code on an empty movie clip, how will I work the graphic part of my preloader? (If all the graphics are on a seperate mc, why bother using an empty movie clip?) Also, why \_level10.gotoAndPlay(2) when you are loading into frame 1?

Sorry… I guess I’m just a bit dense…

---

<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:** [September 21, 2004, 12:47pm UTC](https://forum.kirupa.com/t/preloader-and-external-swf-not-clear-on-how/64857/4 "2004-09-21T12:47:49Z")

</div>

Yeah… I tried it (as I think I understand what you are saying), and it doesn’t work.

☹

Any ideas?
