# Trying to preload a swf that can't be modified

**URL:** <https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676>\
**Category:** flash\
**Created:** [August 29, 2003, 4:56am UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676 "2003-08-29T04:56:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JD44](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@JD44](https://forum.kirupa.com/u/JD44)\
**Post date:** [August 29, 2003, 4:56am UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/1 "2003-08-29T04:56:17Z")

</div>

Hello:

I’m trying to preload a .swf that I can’t change or modify the actionscript for. I made this .swf in another program called xcelsius which takes excel files and converts the data into flash graphs (very cool for what I need it to do), unfortunatley the swf file it creates is around 160k.

I need a preloader that can do what a preloader does, but this preloader can’t be added to the first frame of the loaded swfs .

Make sense?

Any advise someone would give would be swell!

---

<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 29, 2003, 6:28am UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/2 "2003-08-29T06:28:09Z")

</div>

Load it, stop it, set it to invisible, preload it, when preloaded set it back to visible and let it play.

[AS]  
\_root.holder.loadMovie(“xcelsius.swf”)  
\_root.holder.stop  
\_root.holder.\_visible = false;  
l = Math.round(\_root.holder.getBytesLoaded())  
t = Math.round(\_root.holder.getBytesTotal())  
if (l == t) {  
\_root.holder.\_visible = true;  
\_root.holder.play()  
}  
[/AS]

This has to be placed in a loop to work, so we’ll use a movie’s onEnterFrame. I’ll give it the instance name dummy in this example. Place this somewhere on the main timeline:

[AS]  
\_root.holder.loadMovie(“xcelsius.swf”)  
\_root.holder.stop  
\_root.holder.\_visible = false;  
\_root.dummy.onEnterFrame = function(){  
l = Math.round(\_root.holder.getBytesLoaded())  
t = Math.round(\_root.holder.getBytesTotal())  
if (l == t) {  
\_root.holder.\_visible = true;  
\_root.holder.play();  
delete \_root.dummy.onEnterFrame  
}  
}  
[/AS]

That might do it =)

---

<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 29, 2003, 2:00pm UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/3 "2003-08-29T14:00:16Z")

</div>

I’ll give the script a try! Should I use the bottom one or both? I’m still a beginner (sorry).

I am also assuming that the dummy and holder are MC’s, correct? The holder I understand will hold the loaded swf.

Where would you recommend me to put the dummy mc that holds the loop. On the first frame of the main time line or the first frame of the holder? I know you said maintime line but I just wanted to make sure. :crazy:

Thank you sooooo much!

Bebueh!

---

<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 29, 2003, 2:14pm UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/4 "2003-08-29T14:14:20Z")

</div>

– Should I use the bottom one or both?

The first one was the actionscript translation of my first lines. So you should use the second.

– I am also assuming that the dummy and holder are MC’s, correct? The holder I understand will hold the loaded swf.

Correct. Holder is the movieclip to load into and dummy is just an empty movieclip we use for it’s onEnterFrame.

– Where would you recommend me to put the dummy mc that holds the loop ?

Since we use \_root.dummy and not \_root.holder.dummy, on the main timeline.

Remember, the second code has to be on a frame of the main timeline too ! At that frame, it will be loaded.

---

<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 29, 2003, 3:47pm UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/5 "2003-08-29T15:47:32Z")

</div>

I have attached my .fla. It keeps looping and looping

---

<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 29, 2003, 3:51pm UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/6 "2003-08-29T15:51:37Z")

</div>

You forgot to put a stop action at the last frame 🙂

---

<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 29, 2003, 9:48pm UTC](https://forum.kirupa.com/t/trying-to-preload-a-swf-that-cant-be-modified/29676/7 "2003-08-29T21:48:58Z")

</div>

Is it possible to add a progress bar and if so should I put it on it’s own layer on the first frame as well.

I was able to download a bytes based preloader component. Would something like that work for me and would I have to do some adjusting to the component.

Listen I really do appreciate your help. It’s people like you that make these forums worth while for a schmuck like me.

Thanks.

Jason
