A Flash Developer Resource Site

Page 1 of 10 12345 ... LastLast
Results 1 to 20 of 189

Thread: For everyone with a preloader problem

  1. #1
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365

    For everyone with a preloader problem

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

    totalBytes = this.getBytesTotal();
    loadedBytes = this.getBytesLoaded();
    remainingBytes = totalBytes - loadedBytes
    percentDone = int((loadedBytes/totalBytes)*100);
    bar.gotoAndStop(percentDone);
    if (_framesloaded == _totalframes) {
    gotoAndPlay(3);
    }


    (with an MC instance named "bar" as the loading bar).

    and on frame two:
    code:
    gotoAndPlay(1);



    Let me break it down:

    totalBytes = this.getBytesTotal();
    loadedBytes = this.getBytesLoaded();
    remainingBytes = totalBytes - loadedBytes
    percentDone = int((loadedBytes/totalBytes)*100);
    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.

    EDIT:Preloaders: Seperate Preloaders

    These are most useful when making a photo gallery or something, so that you can load each picture seperately. I found a great tutorial, have a look:
    http://www.kirupa.com/developer/acti...cliploader.htm


    Preloaders: Adding the [%] Sign Using AS

    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:

    "percent = int((loadedBytes/totalBytes)*100);
    percentDone = percent+"%";"


    Preloaders: How to make them look fluent

    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:

    For creating basic preloaders:

    http://learningflashmx.com/flashmx_p...r_tutorial.htm

    http://www.flashkit.com/tutorials/In...a-33/index.php

    http://actionscript.org/tutorials/be...er/index.shtml

    For creating more advanced preloaders:

    http://www.flashkit.com/tutorials/Ac...-612/index.php

    http://www.kirupa.com/developer/acti..._preloader.htm


    I hope that helps!

    ~Sportzguy933

    P.S.
    Anybody with more help, tips, etc., feel free to add! If you need help with preloaders, just post it here!
    Last edited by sportzguy933; 02-17-2006 at 09:16 PM.

  2. #2
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    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

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    *I am using it for your website, mind, or I probably do a simple preloader...*
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    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:

    http://www.kirupa.com/developer/acti...cliploader.htm

    EDIT: But now that I think of it, the way I linked to, may not be very useable for a game or such, please pm me, or post your scenario.
    Last edited by sportzguy933; 11-26-2005 at 08:08 PM.

  5. #5
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    What a useful thread !

    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)

    :: SASHA-Z-CREATIONS :: web site

  6. #6
    Member
    Join Date
    Sep 2005
    Posts
    71
    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.

  7. #7
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Here you go:

    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.
    Attached Files Attached Files
    Last edited by sportzguy933; 11-27-2005 at 02:32 PM.

  8. #8
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Ok.. I can't play that file in flash 8.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  9. #9
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Hmm..... I'll take a look.

  10. #10
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    never mind... I only need a persentage loader now.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  11. #11
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    That's odd... opens fine for me in Flash 8. I uploaded the F8 version.
    Attached Files Attached Files

  12. #12
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Let me know if it works.

  13. #13
    The Summoner
    Join Date
    Sep 2005
    Location
    (>")> (>"<) <("<)
    Posts
    53
    Excellent thread Sportzguy! VERY informative! This should definitely be sticky!!

  14. #14
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Yea... Excellent!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  15. #15
    Junior Member
    Join Date
    Jun 2001
    Posts
    13
    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:

    Code:
    my_Date = new Date();
    my_xml = new XML();
    my_xml.ignoreWhite = true;
    my_xml.load("master.xml?"+my_Date.getUTCSeconds());
    my_xml.onLoad = function() {
    	the_xml = this.firstChild;
    	_root.image = the_xml.childNodes[0].childNodes.join("");
    };
    stop();
    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.

  16. #16
    if you go first
    Join Date
    Oct 2005
    Location
    Herts, UK
    Posts
    62

    Can anyone help me???

    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.

    -----------------------------------------------------------

    Hey,

    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".

    Is this the problem? What can I do?

    The movie is here:
    http://www.pc16.net/chris/city/cityjjLoader.swf
    and the .fla here:
    http://www.pc16.net/chris/city/cityjjLoader.fla
    but this link might crash your browser - it did mine (Firefox)! You know why?

    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

  17. #17
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    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

  18. #18
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Answer to: srieger

    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!

    ~Sportzguy933

  19. #19
    if you go first
    Join Date
    Oct 2005
    Location
    Herts, UK
    Posts
    62

    I don't think that's it

    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?

    I can't be the first person in this situation!

    Thx a lot,
    Chris

  20. #20
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    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.

    ~Sportzguy933

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center