Frustrations

i have some preloader frustrations…dont point :sleep: me to a previous preloader thread…i have been there already and no im not talking about any preloader that loads the WHOLE movie at the beginning, i know how those work… I need a tutorial/explanation that will teach me how to load a move ‘button by button’ or ‘page by page’.

By this I mean, the first thing the movie will do is load the first ‘page’ and say you have a few more buttons on that ‘page’. It loads all the buttons and that ‘page’ first…nothing else…
then i click one of the buttons (no matter what order) and the ‘page’ switches to a preloader and then when the second ‘page’ is loaded, it is displayed.
So many sites have this kind of preloader…but i cant believe how many tutorial sites only teach how to program the type of preloader that just loads the WHOLE movie. Im frustrated because i have been looking for this type of preloader for years and seem to have no luck even experimenting myself.

2advanced
is a great example of what i need…it has that preloader come up everytime it tries to access a completely new ‘page’

Thanks

One way of doing that is making each section of your site a separeate swf with a loadbar in the beggining of them.
Another way is using a single loadbar on your main movie and set a function to tell flash which movie to preload.

should i use IfFramesLoaded,
_root.MovieClipName.getBytesTotal() or something else for the preloader if i use your second suggestion of using a function.

Is there any way to load movies out of the library and put them on the scene during runtime and put old ones back into the library?

Thanks

If you want to use a single loadbar to all externals:
create an empty movie clip and apply the following code on it:[AS]onClipEvent (enterFrame) {
if (this._url != _root._url) {
_root.preload(this);
}
}[/AS]Now place the following code the 1st frame of your main timeline:

function preload(clip) {
	if (!loaded) {
		if (clip.getBytesLoaded>0 && clip.getBytesLoaded>=clip.getBytesTotal) {
			loaded = true;
		}
		var percent = (clip.getBytesLoaded()/clip.getBytesTotal());
		loadBar._width = 100*percent; //replace 100 for your loadbar width
	}
}
button.onPress = function() {
	loadMovie("yourmovie.swf", container_mc);
};[/AS]

nice example claudio.

This is what I posted before I saw claudio’s example

a command for getting the bytes might look something like this, in a dynamic preloader

_root[mcToLoad].getBytesTotal();

in this OOP you can change the variable “mcToLoad” to be equal to whatever movie clip you have on the main timeline that is loading.

loading movies from the library, to the stage at run time is called “attaching” a movie. In order to use the attachMovie(); method you will need to right click on the item in the library, choose “linkage”, and then set it to “export for use with actionscript” (or something like that… I can’t quite remember the exact wording.) From there it should be pretty easy to see how attachMovie is used.

If you attach a new movie, to the same location and depth of any movie that is currently playing, it will automaticaly unattach that movie in place of the new one. The movie is still in cache however, so recalling it is almost instantanious.

Further help may be found by using the search feature on the following key words. “AttachMovie, Linkage”

hope that helps. :slight_smile:

Thanks upuaut :slight_smile:

thanks a lot both of you, I will experiment with it and bug you again if i cant get it right…

welcome :slight_smile:
good luck for you

onClipEvent (load) {
clicked = “about”;
_root.location.attachMovie(“Home_Movie”, “About”,1);
if (clicked == “about”) {
_root.location.attachMovie(“Home_Movie”, “About”,1);
} else if (clicked == “portfolio”) {
_root.location.attachMovie(“Train_tracks”, “Portfolio”,1);
} else if (clicked == “marketing”) {
_root.location.attachMovie(“Airplane_Movie”, “Marketing”,1);
} else if (clicked == “contact”) {
_root.location.attachMovie(“Cat_5_Wire”, “Contact”,1);
}
}

ok i have that much and it works…but i need to load each movie separately…i cant think of a way to do this…and is there another way than placing the attached movie just on the first frame?

Thanks

Load the movies into an empty movie clip. Paste the following code on the first frame of the main timeline.
[AS]button1.onPress = function() {
loadMovie(“yourmovie1.swf”, container_mc);
};[/AS]Apply the same code for button2, button3, etc…

well, i dont want to use your solution of exporting each movie for whichever button…i dunno why but i dont trust it doing it that way…instead i want to attach a movie when a button is pressed but dont know how to preload something like that

or am I just being ignorant and totally missing what you are trying to say? :cyclops: lol

Thanks