# Preloading content

**URL:** <https://forum.kirupa.com/t/preloading-content/28963>\
**Category:** Uncategorized\
**Created:** [August 20, 2003, 3:42pm UTC](https://forum.kirupa.com/t/preloading-content/28963 "2003-08-20T15:42:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brown0209](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Brown0209](https://forum.kirupa.com/u/Brown0209)\
**Post date:** [August 20, 2003, 3:42pm UTC](https://forum.kirupa.com/t/preloading-content/28963/1 "2003-08-20T15:42:10Z")

</div>

Hi. Im having trouble a problem with my  
flash movie. I didnt notice it was a problem  
until I uploaded it to the web. Heres the problem:

I have dynamic text, .jpg’s, and .swf’s loading  
into different parts of my movie. The file size of  
them is fairly small, but I notice that they are  
still taking a few seconds to show, so what  
I want to do is make the movie pause until the  
text, .jpg’s, and swf’s are fully loaded. I want to  
have ‘loading’ text showing so the user knows that  
the content is loading.

I found this tutorial on the site

‘Preloader and Transition for Dynamic Files’

but I am a little confused by it. I cant relate it  
to my project because I am trying load more  
than just one object on a frame.  
I also dont need any fancy transition that this  
tutorial uses. Just plain and simple.  
Can someone please help me. Thank you =)

Brown ☹

---

<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 20, 2003, 9:03pm UTC](https://forum.kirupa.com/t/preloading-content/28963/2 "2003-08-20T21:03:44Z")

</div>

You could use just a regular preloader…[http://www.kirupa.com/developer/mx/percentagepreloader.htm](http://www.kirupa.com/developer/mx/percentagepreloader.htm)

---

<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 20, 2003, 9:20pm UTC](https://forum.kirupa.com/t/preloading-content/28963/3 "2003-08-20T21:20:00Z")

</div>

Ive tried that. I know I have to load them from the  
main movie, not the individual movies themselves.  
And besides, most of the things I am loading are  
text files. You can place a loader into a text file.  
Thanks anyway Blackjack. At least I got 1 reply so far…

---

<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 20, 2003, 9:29pm UTC](https://forum.kirupa.com/t/preloading-content/28963/4 "2003-08-20T21:29:14Z")

</div>

You can make something like this: since you are using LoadVars, you could set an animation (like a “loading” message blinking) while the onLoad hasnt been completed.  
ie:  
[AS]loading\_mc.\_visible = true;  
var myLoadVars = new LoadVars();  
myLoadVars.load(“news.txt”);  
myLoadVars.onLoad = function(success) {  
if (success) {  
loading\_mc.\_visible = false;  
myText.text = this.myVar;

```
} else {
	loading_mc._visible = false;

```

myText.text = “Error!”;  
}  
};

```auto

```

---

<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 21, 2003, 12:02am UTC](https://forum.kirupa.com/t/preloading-content/28963/5 "2003-08-21T00:02:30Z")

</div>

I dont really understand this code. How will the main  
movie know when the files are loaded. Let me give an example:

I press a button and it brings me to a page with

1 external jpg  
3 dynamic html text fields (from .txt files)  
2 external swf’s

How do I pause the movie, bring up a loading animation, load the 6 files, then play the movie?

---

<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 21, 2003, 1:23am UTC](https://forum.kirupa.com/t/preloading-content/28963/6 "2003-08-21T01:23:17Z")

</div>

I found a code that seemed like it would work and tried to  
apply it to my problem,…but it didnt work.  
Can someone tell me if this sounds right:

stop(); // stop the timeline  
num = 0  
myFiles = [“NEWCD.txt”,“NEWCD.jpg”,“mixedcd\_nav.swf”];

function loadScene(num){  
if (num \< myFiles.length){  
\_root.loading\_mc.\_visible = 1;  
this.createEmptyMovieClip(“controller”,1000000);  
this.createEmptyMovieClip(“container”,1000001).\_visible = 0;  
container.loadMovie(myClips[num]);  
controller.onEnterFrame = function(){  
var l = container.getBytesLoaded();  
var t = container.getBytesTotal();  
if (l \>1 && l \>= t) {  
\_root.loading\_mc.\_visible = 0;  
delete this.onEnterFrame;  
num++;  
loadScene(num);  
controller.removeMovieClip();  
container.removeMovieClip();  
}  
}  
}  
}

---

<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 21, 2003, 2:02am UTC](https://forum.kirupa.com/t/preloading-content/28963/7 "2003-08-21T02:02:45Z")

</div>

Check this:

> **[Yahoo Small Business - Cheap Domains, Web Hosting, Website Builder, Ecommerce...](https://smallbusiness.yahoo.com/)**
>
> Yahoo Small Business Offers Cheap Domain Names, Web Hosting, Easy Website Builder, Business Email, Local Listings, and Ecommerce Solutions for Your Small Business.

[edit]this is the code i used:

```auto
function loadData() {
	loading_mc._visible = true;
	var myLoadVars = new LoadVars();
	myLoadVars.load("news.txt");
	myLoadVars.onLoad = function(success) {
		if (success) {
			loading_mc._visible = false;
			myTextField.text = this.myVar;
		} else {
			loading_mc._visible = false;
			myTextField.text = "Error loading data!";
		}
	};
}
loadData();

```

[/edit]

---

<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 21, 2003, 5:05am UTC](https://forum.kirupa.com/t/preloading-content/28963/8 "2003-08-21T05:05:04Z")

</div>

maybe I am not explaining this right.  
I think it would be easier if you seen what  
I am trying to do. I used some of you code  
to do this but it is still not working correctly.

check it out for yourself :

[http://www.digitalmixmaster.com/flash.htm](http://www.digitalmixmaster.com/flash.htm)

dont mind the mess, it still needs some work.

Anyway, the only preloads I added were to the ‘Remixes’ button and the ‘Mixed CD’ button. click them to see what I am trying to do and what is going wrong. Thanks, Laterz!

Brown
