Preloading content

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 :frowning:

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

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…

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!”;
}
};

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?

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();
}
}
}
}

Check this:

[edit]this is the code i used:

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]

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

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