# Preloading external swfs problem again

**URL:** <https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508>\
**Category:** Uncategorized\
**Created:** [November 14, 2003, 7:00pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508 "2003-11-14T19:00:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nizamm](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nizamm/32/7613_2.png) [@nizamm](https://forum.kirupa.com/u/nizamm)\
**Post date:** [November 14, 2003, 7:00pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/1 "2003-11-14T19:00:50Z")

</div>

Fine fine…I know it’s been asked too many times. But my problem is kinda different. All I want to know is: To preload external swfs, should I make a preloader within the swf or should there be a preloader in the parent movie calling the external swf?

Well, all the external swfs I’ve made so far have their own preloader and it works fine when they run independently. The trouble comes when the main movie calls it. The preloader simply doesn’t run. The screen just shows the bg color for few seconds and loads the new content…[content size 30-40k]

_for those who think this question’s been asked too many times_

Well I searched and got links talkin about some sorta movie linkage and attach movie and dunno what…but I was looking forward in doing something far much simpler than those…I mean…if the preloder works independently for each swf, why shouldn’t it when a parent movie calls it!!!

Thanks in advance…

---

<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:** [November 14, 2003, 7:02pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/2 "2003-11-14T19:02:31Z")

</div>

You are probably using \_root in the preloader script of the external swfs. Can you give us the preloader code you used ?

---

<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:** [November 14, 2003, 7:10pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/3 "2003-11-14T19:10:29Z")

</div>

Heres one script that uses a preloder only on the main movie:

```auto
//objects on stage:
//inside the parenthesis is the instance name
//empty movie clip (holder)
//textfield - (myTextField)
//loadbar movie clip - (loadBar)
//load bar border movie clip - (border)
loadBar._visible = false;
border._visible = false;
loadClip = function (clip) {
	holder.loadMovie(clip);
	preload();
};
preload = function () {
	this.createEmptyMovieClip("temp", 1000);
	temp.onEnterFrame = function() {
		var t = holder.getBytesTotal(), l = holder.getBytesLoaded();
		if (t && !isNaN(t)) {
			loadBar._visible = true;
			border._visible = true;
			var percent = Math.round(l*100/t);
			if (l == t) {
				myTextField.text = "Done";
				loadBar._visible = false;
				border._visible = false;
				this.removeMovieClip();
			} else {
				myTextField.text = +percent+" %";
				loadBar._width = (l/t)*100;//100 is the loadbar width
			}
		}
	};
};
//usage
mybutton.onPress = function() {
	loadClip("yourfile.swf");
};

```

Heres a sample fla

---

<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:** [November 14, 2003, 7:10pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/4 "2003-11-14T19:10:35Z")

</div>

I guess you’re right…anyway…here’s the code…

[AS]

// Action script…

// [Action in Frame 1]  
tellTarget(“Preloader”)  
{  
gotoAndPlay(Math.round(\_root.getBytesLoaded() / \_root.getBytesTotal() \* 100))  
} // end of tellTarget

// [Action in Frame 2]  
if (\_root.getBytesLoaded() == \_root.getBytesTotal())  
{  
gotoAndPlay(3);  
}  
else  
{  
gotoAndPlay(1);  
} // end if

// [Action in Frame 12]  
stop();

[/AS]

---

<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:** [November 14, 2003, 9:06pm UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/5 "2003-11-14T21:06:43Z")

</div>

not to jump off the thread here but Tell Target really doesn’t serve any purpose anymore, it’s just not needed, clauido great script, you amaze me

---

<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:** [November 16, 2003, 10:20am UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/6 "2003-11-16T10:20:33Z")

</div>

> \*Originally posted by Voetsjoeba \*  
> \*\*You are probably using \_root in the preloader script of the external swfs. Can you give us the preloader code you used ? \*\*

Voetsjoeba, I tried what you said. But the script is made in such a way, I HAVE to use \_root in the external movie…So what do i do? I want to know how to successfully make an external swf preload itself when called by a main movie…

Claudio…I checked the fla but…I think it’ll take time for me to implement that lot to my current structure I have…Right now, I gotta get the current structure working…and that’s simply by making the external swfs preload properly…know any way apart from removing the ‘\_root.’ statement?

---

<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:** [November 16, 2003, 10:29am UTC](https://forum.kirupa.com/t/preloading-external-swfs-problem-again/35508/7 "2003-11-16T10:29:08Z")

</div>

Why do you _have_ to use \_root ?
