A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: My preloader dont work right all the time!! help

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    87

    My preloader dont work right all the time!! help

    Hi
    I have this script for a preloader that i used on 2 pages and worked just fine but on my last page the preloading starts working when the loading is at 50% until then its all white.
    code:
    stop();
    myInterval = setInterval(preloader,10);
    function preloader() {
    if (getBytesLoaded() >= getBytesTotal()) {
    play();
    clearInterval(myInterval);
    }
    progressBar._xscale = (getBytesLoaded()/getBytesTotal())*100;
    }



    Can anyone tell me whats the problem?, i thing is my page not the preloading since it works fine on 2 pages.

    Thank you very much.

  2. #2
    Member
    Join Date
    Jan 2004
    Posts
    87
    I have tryed with some preloaders i found on this forum and my probles is still the same , so i quess is not the preloader.
    Any ideas?

  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    87
    I have tryed with the preloader in other stage, and i have the same problem, i so wierd.

    I think i'm going mad in here I'm over the deadline
    Last edited by maydays; 06-18-2004 at 04:43 PM.

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Posts
    2,467
    Hi:

    Try the following:


    stop();
    loaded=getBytesLoaded();
    total=getBytesTotal();
    myInterval = setInterval(preloader,10);
    function preloader() {
    if (loaded == total && total > 1) {
    play();
    clearInterval(myInterval);
    }
    progressBar._xscale = ((loaded/total)*100);
    }



    I highlighted the important part:

    if (loaded == total && total > 1)




    -james
    Last edited by jamescover; 06-18-2004 at 05:43 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life."

    Image Popup Scripting Engine | Thumb PopUp Script | HTML Anchors w/Flash | Popup Script Generator | Seq. Img Swap | Img Swap | Browser Shake | Rand. Img Swap | Inline Img Swap | Screen Res. PopUp | Screen Resolution Popup Script


  5. #5
    Senior Member
    Join Date
    Jul 2002
    Location
    Slovenia
    Posts
    193
    Hmmm. Jamescover I think this code isn't allright. His code is totally fine.

    Maydays do you have a lot of pictures in your last page? Is the last swf of you page quite big? Do you export a lot of symbols for use in actionscript in the first frame?

    Because what you have told might happen when you have a lot of symbols that are exported in the first frame (usually they take up more than 50% of the entire swf file). Note that this is because all those symbols are loaded first and only then the actual movie is loaded. You can overcome this problem by loading this swf from another swf and watch its progress from within the first swf.

    If you need more help wait till tomorrow.

  6. #6
    Senior Member
    Join Date
    Nov 2003
    Posts
    524
    Hey MayDays,
    I agree with MatejKo. That it is most probably not the code itself but rather that the code is in the loading .swf.
    But depending on the structure of your project that could cause all sorts re-work which it sounds like you do not have time to do.
    I would advise that you post your .fla file and ask for some hands on help. And meanwhile spend a minimal amount of time coming up with a bandaid in case the cure takes a while.

    If you have MX windows (2003) I have the time right now to give you a hand.
    Shipstern

  7. #7
    Junior Member
    Join Date
    Jun 2004
    Posts
    1

    I have the same problem with an external movie clip

    Hello MatejKo,

    I have had the same problem with a preloader, because Flash MX only allows you to link movie clips to frame 1.

    I tried to solve it as you suggested by first making the preloader, and afterwards loading a .swf-file into the preloader as a movie clip.

    Unfortunately I cannot make it work. It seems that the getBytesTotal and getBytesLoaded cannot be used on a movie clip?

    Do you have any suggestions?

    Best regards, Chaudhry.


    Originally posted by MatejKo
    Hmmm. Jamescover I think this code isn't allright. His code is totally fine.

    Maydays do you have a lot of pictures in your last page? Is the last swf of you page quite big? Do you export a lot of symbols for use in actionscript in the first frame?

    Because what you have told might happen when you have a lot of symbols that are exported in the first frame (usually they take up more than 50% of the entire swf file). Note that this is because all those symbols are loaded first and only then the actual movie is loaded. You can overcome this problem by loading this swf from another swf and watch its progress from within the first swf.

    If you need more help wait till tomorrow.

  8. #8
    Member
    Join Date
    Jan 2004
    Posts
    87
    Hi
    First I want to thank you guys for the replays ..


    I tried every thing, I started first by deleting layer by layer and symbol by symbol and I found the problem.Now all i have to do is solving it.

    I have this script in frame 10
    :
    code:
    _root.createEmptyMovieClip("empty_Mc",1);
    setProperty("_root.empty_MC", _x, 561);
    setProperty("_root.empty_MC", _y, 321);



    and this script on the buttons:
    (I have 9 button and 9 MC in Libraly with the linkage.. name for each one(“bt1_info”.)

    code:
    on (release) {
    _root.empty_Mc.attachMovie("bt1_info","bt1_info",1 );
    }



    that loads a movie clip from the library, that is not on the stage in the first place.

    So if I delete this MCs ((“bt1_info”, (“bt2_info”)…) from the library the preloader is working fine.

    So the only way I can think to solve this problem is by putting the MCs on the stage in the first place.But than I wouldn’t use that cool script “_attachMovie()”

    If u have any idea how to do this with the “_attachMovie()” on, and make the preloader work fine plase let me know.

    Thank you very much for your time and please excuse me English.
    Last edited by maydays; 06-27-2005 at 09:02 PM.

  9. #9
    Senior Member
    Join Date
    Jul 2002
    Location
    Slovenia
    Posts
    193
    You may want to look at the homepage of my class (this is where I use the previously escribed method; just look at the PRELOADER.MODULE at the top-centre part of the popup screen): http://www.druga.org/~raz00m/

    Here is a sample code to be used to achieve this:

    1. The following code is in the main swf
    code:

    // Load the preloader module into the _level10 for
    // example, but be sure that you load the preloader
    // module first and that it is very small in size!
    loadMovieNum("the_preloader.swf", 10);


    // Load a movie clip into the _level1
    loadMovieNum("some_clip.swf", 1);

    // Somehow tell the preloader that there has been a movie
    // loaded in the 1st level
    _global.currentlyLoadingMovies=new Array();
    _global.currentlyLoadingMovies.push("_level1");



    2. The following code is in the preloader module:
    code:

    // Lookup how much bytes has each _level
    onEnterFrame=function(){
    var bytes_total=0;
    var bytes_loaded=0;
    for(i=0;i<_global.currentlyLoadingMovies.length;i+ +){
    // Store the current movie for faster referecing
    current_movie=_root[_global.currentlyLoadingMovies[i]];
    current_total=current_movie.getBytesTotal();
    current_loaded=current_movie.getBytesLoaded();
    bytes_total+=(current_total < 0)?0:current_total;
    bytes_loaded+=(current_loaded < 0)?0:current_loaded;
    }
    percentage=Math.round(bytes_loaded/bytes_total*100);
    }
    // Note: When you unload a movie from a level
    // you must splice the corresponding element from the
    // _global.currentlyLoadingMovies array - this makes
    // the code more efficient.



    Hope this helps...

    [EDIT:] I have changed the code a little, and have put a comment in the last line of the second code.
    Last edited by MatejKo; 06-19-2004 at 02:49 PM.

  10. #10
    Senior Member
    Join Date
    Nov 2003
    Posts
    524
    Hi maydays,
    I have a suggestion:
    If the 9 Movie Clips in the library and attaching them is causing problems. Then why not make them individual Movie Clips and use loadMovie to load them into the empty_Mc. Thats a cool script too!!

    ie:

    root.createEmptyMovieClip("empty_Mc",1);
    setProperty("_root.empty_MC", _x, 561);
    setProperty("_root.empty_MC", _y, 321);

    //script on button
    on (release) {
    _root.empty_Mc.loadMovie("bt1_info.swf");
    }

    Of course your design may not allow for any delay between the button release and the display of "bt1_info.swf".

    Just an idea
    Shipstern

  11. #11
    Member
    Join Date
    Jan 2004
    Posts
    87
    Hi
    Thank you guys for all the help, i will use yours ideas.
    You realy help me a lot thanks again.
    See you

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