Hi. I'm making this thread in response to all of the preloader help posts there are.
Preloaders can be incredibly simple, to extremely complex, this is why most people have problems with them. Sometimes it's an instance name, and sometimes it's a piece of AS. It can be almost anything.
Preloaders: How it works
Preloaders are a way of loading your movie without having your visitors staring at a blank page. Basically, a preloader bounces between two frames, until it is all loaded. It uses dynamic text boxes to display the percent [%] loaded, and a bar animation to show the percent loaded visually, or can display a continuous animation instead.
Preloaders: The Actionscript
There is a somewhat standard actionscript used in preloaders, it is:
on frame one:
Set the variables that will be used later in the script.
bar.gotoAndStop(percentDone);
Go to the number of percent done (loaded), such as 50, on "bar"'s timeline, which is exactly 100 frames.
if (_framesloaded == _totalframes) {
gotoAndPlay(3);
}
If all the content in the movie is LOADED, go to and play Frame 3, which consists of the movie's content.
gotoAndPlay(1);
This is on Frame two, and is how the movie "bounces back and fourth" between frames.
So basically, the AS is figuaring out how much is loaded, and displaying it, and if everything is loaded, continue.
Preloaders: The rest of it
There are other components of a preloader, such as the bar, and dynamic text boxes. These show the percent loaded, both visually and numerically. These aren't required, but are almost always included (at least one of the two). Some people prefer a continuous animation, and a "Loading..." text, but most preloaders consist of both.
This is something I was searching for when I made a more advanced preloader, and wanted the [%] sign to be dynamically added, and perfect.
You can replace "percentDone =" (asssuming you are using a preloader script that is somewhat like the tutorial at learningflashmx.com (see tutorials section), and percentDone is the var name of your dynamic text box), With:
This is a question I had a while ago about how to make my preloader less choppy. I had followed a tutorial, and left my FPS rate at 12, not knowing any better. When I found out that the main cause of this was because my FPS rate was too low, I got very frustrated, since I had already created my site. This is the one thing where you really can't be helped, I'd loved to be proven wrong though.
Preloaders: Tutorials
If you would like some step-by-step instruction to creating a preloader, try some of these:
Any ideas on seperate Preloaders loading at the same time? in which one bar presents the loading of sound, while the other bar repersents the loading of images??
Thanks, Sportzguy933.
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
Well, the best way to do that would be to just load external clips, and have a preloader on each one, but there are other, maybe better ways to do that:
Thank you sportzguy, I'm sure this will help a lot of people in this wonderful forum. I've notice so many people are asking exactly the same question all over again. Threads like this one should be pinned and always on the top of all threads, so everyone can easily find it in case they need some preloader related info.
Regards!
:: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)
How can I make a Super Basic preloader, no percent or anything, just a little thing that says "loading..." and then it checks to see how much is done? I don't need to show the percent or bytes or anything, just the shortest way possible.
Make a new scene. Open the scene panel (windows>other panels>scene panel), and drag it before Scene 1.
Put this on the first frame of the Actions Layer:
code:
if (_framesloaded == _totalframes) {
gotoAndPlay(3);
}
Then on Frame 2:
code:
gotoAndPlay(1);
And on Frame 3:
code:
nextScene();
Then make a new layer and just make static text that say: Loading...
Lastly, make sure to put a stop(); action some point in the next scene (most likely the first frame).
I also attached one that I made. It has the percent loaded, and a bar. Just copy and paste the frames onto a new scene that is before your content, but the one I explained above should work just fine .
~Sportzguy933
P.S
Tell me if you need the MX version.
Last edited by sportzguy933; 11-27-2005 at 02:32 PM.
Great thread! I do have a question though.. perhaps a little more advanced, but I am loading in an XML file in my first frame that has the location variable of a .jpg which gets loaded into the Loader component later in the movie. If I drop a preloader in and have it watch the loader component will it only track the compnent itself or will it basically be preloading the jpg in the component.
So basically the XML in frame one looks like this:
Then on the frame that the Loader component is on I load that variable (which is a jpg in the XML file)
Code:
loader.contentPath=_root.image;
loader.load();
So my question is.. how do I get a preloader to jump to say frame 15 ONLY after the loader component has fully loaded the .jpg?
Thanks for any help anyone can offer me. This one has me stumped.
The links here are now broken. I now use Flash 8. I had sorted this problem out by having a holder.swf load preloader into _level2 and the main.swf into _level1, and using _level1.getBytesLoaded() or something like that - can't reember.
The website is now: www.camjj.co.uk, but I'm still finishing off the Flash version.
I use FLash 5 and my preloader isn't really doing what it's supposed to do! I'd love someone to help me sort this out!
I've uploaded it and tested it, but I just get a blank screen until (practically at least) the entire movie's downloaded then it flashes up (near) 100% and plays the next scene.
How do I make sure it's functional and not just cosmetic?
Here's an image of the problem: http://www.pc16.net/chris/city/problemImage1.jpg
How can I use this to fix it?
The movie is about 1 megabyte - and it seems it's all in the first frame! Is this because of my library? Virtually everything is in the library - ie everything is a movieclip and is "exported" under "linkage properties".
Can I use the following with a separate .swf for my loader?
anyMovieClip.getBytesLoaded();
Method: returns the number of bytes loaded (streamed) for the specified Movie Clip object. Because internal movie clips load automatically, the return result for this method and MovieClip.getBytesTotal will be the same if the specified Movie Clip object references an internal movie clip.
This method is intended for use on loaded movies. You can compare the value of getBytesLoaded with the value of getBytesTotal to determine what percentage of an external movie has loaded.
Thanks a lot for your help,
Chris
Last edited by flashMine; 04-16-2006 at 11:44 AM.
Reason: Broken Links
Hi. I think your problem is your actual preloader. If there is an animation to go with it, I highly reccomend loading it externally. Another thing to do is to move your preloader to another scene (before your movie), and use the nextScene(); action instead of gotoAndPlay(w/e); or gotoAndStop(w/e); action(s). This may take some weight off from bitmaps.
Good Luck,
Sportzguy933
The loader component should watch the jpg, from what I understood from your description. But try being a little more clear with what you're saying about jumping frames. Also, why don't you give it a try and see if it works!
Thanks for trying to help and sorry for double-posting - I was worried that no one would read the longer thread.
My preloader is in a scene on its own. Did you look at the picture of the problem? It looks like practically the entire movie (weighted byte-wise) is in the first frame. and so nothing is played until the first frame (ie just about all of the movie) is fully loaded. How do I combat this?
How so I use the "anyMovieClip.getBytesLoaded()" command on an external swf?
Can anyone explain why there's nearly 1 MB in the first frame?
Hi. Sorry, I was in a rush and didn't get a chance to look at the picture. I don't use the
mc.getBytesLoaded();
action on external SWF's, but I'm guessing it would be the target MC to get the "bytesLoaded" from, but I could easily be wrong. Maybe someone else could help you out. Actually, I find the best way (in terms of ease) is to have a preloader on the SWF loading, and just load it.