# Preloading external swf?

**URL:** <https://forum.kirupa.com/t/preloading-external-swf/15955>\
**Category:** flash\
**Created:** [March 19, 2003, 7:38pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955 "2003-03-19T19:38:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![p13](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@p13](https://forum.kirupa.com/u/p13)\
**Post date:** [March 19, 2003, 7:38pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/1 "2003-03-19T19:38:32Z")

</div>

I’m loading an external swf into a blank movie clip and I would like to add a preloader to it. I’ve used this code for my preloader:

onClipEvent (enterFrame) {  
var bytes = \_root.getBytesTotal();  
var bytes\_loaded = \_root.getBytesLoaded();  
if (bytes\_loaded == bytes) {  
\_root.gotoAndPlay(2);  
this.pootxt = “movie loaded”;  
} else {  
\_root.gotoAndStop(1);  
this.pootxt = “loading (” + bytes\_loaded + “/” + bytes +")";

```
}

```

}

It does not seem to work. I think (and I could be way off as I’m pretty new at this) that the \_root.gotoAndPlay(2) is the cause of the problem. It seems to target my main timeline instead of the external swf…

Any help will be much appreciated…

Thanks,

-P.

---

<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:** [March 19, 2003, 7:44pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/2 "2003-03-19T19:44:53Z")

</div>

pretty much yes 🙂

replace **\_root** with **[color=red]this[/color]** =)

---

<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:** [March 19, 2003, 7:56pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/3 "2003-03-19T19:56:17Z")

</div>

“\_parent” seemed to work, is “this” better?

-P.

---

<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:** [March 19, 2003, 7:59pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/4 "2003-03-19T19:59:02Z")

</div>

oh wait … :crazy:

if the code is in a movie clip in the swf then yes … use **\_parent**  
i thought it was in the movie clip that loads the swf 😛

---

<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:** [March 19, 2003, 8:05pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/5 "2003-03-19T20:05:40Z")

</div>

Thanks a bunch…🙂

-P.

---

<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:** [March 19, 2003, 8:08pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/6 "2003-03-19T20:08:57Z")

</div>

no problem 😉

but … i didn’t do anything this time 😛

---

<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:** [March 19, 2003, 8:11pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/7 "2003-03-19T20:11:27Z")

</div>

lol! =)

---

<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:** [March 19, 2003, 8:14pm UTC](https://forum.kirupa.com/t/preloading-external-swf/15955/8 "2003-03-19T20:14:03Z")

</div>

:crazy: 😉

oh well … i should get back to work :-\
