A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Pre-loader's not working

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Posts
    156
    I'm trying to create a pre-loader, but the action script I am acustomed to using in Flash 5 doesn't seem to be working in flash 6. What am I doing wrong?

    This is my script:

    gotoAndPlay(18);
    ifFrameLoaded (70) {
    MovieClip.gotoAndPlay(26);

    Except when I test the movie it just keeps looping the loop instead of moving past it when the last frame is loaded.

    Thanks for your help.


  2. #2
    Junior Member
    Join Date
    Oct 2001
    Posts
    8

    Red face preloader? hmmm

    Yep... I have this problem too.... apparantly you should use _framesloaded but an example would be nice..

  3. #3
    Member
    Join Date
    Jul 2001
    Posts
    72

    Smile Pre-loader

    Originally posted by karidee
    I'm trying to create a pre-loader, but the action script I am acustomed to using in Flash 5 doesn't seem to be working in flash 6. What am I doing wrong?

    This is my script:

    gotoAndPlay(18);
    ifFrameLoaded (70) {
    MovieClip.gotoAndPlay(26);

    Except when I test the movie it just keeps looping the loop instead of moving past it when the last frame is loaded.

    Thanks for your help.

    What do you mean by Flash 6? There's nothing called Flash 6, may be you're using the beta version of Flash MX. Try upgrading it to Flash MX.

  4. #4
    Junior Member
    Join Date
    Oct 2001
    Posts
    8
    No I am using MX, You can still use the if frames loaded action but its depracated..... so you have to use the _framesloaded action which is good as you can use your own if/else statements....... just wish i knew action script a bit better as Id show an example (hint hint)

  5. #5
    Senior Member
    Join Date
    Dec 2001
    Posts
    156
    Yes, I'm using MX as well, I just called it 6 because it was easier and it is the 6th incarnation of the fLash program. Thanks for the tip on the Framesloaded. It's a good lead! But, if anybody does have an example that would be really wonderful!!!!!! Thanks

  6. #6
    Junior Member
    Join Date
    Oct 2001
    Posts
    8

    preloader

    I found one that works fine and creates a percentage bar if that helps :
    http://www.actionscripts.org/tutoria...s/index2.shtml

    It doesnt cause any problems in the Flash player.

    Hope it is of some use... if i crack the _framesloaded malarky Ill let you know

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Simply...

    if(_framesloaded >= _totalframes){
    gotoAndPlay("Scene 1", 1);
    }

    But, if you use that, and only load a certain amount of frames (_totalframes/2, for instance, hoping the rest of the movie downloads while it streams), that might not be allways as accurate as bytes loaded, because some frames might be heavier than others.

    Thus...

    if (_root.getBytesLoaded() >= _root.getBytesTotal())){
    gotoAndPlay("Scene 1", 1);
    }

    ...Would be better!

  8. #8
    Senior Member
    Join Date
    May 2000
    Posts
    185
    I got the tutorial that sushin provided a link to and it works fine but my problem is this.

    How do I set this code to be a preloader for an external movie clip. You know when I call the loadMovie funtion and load the external swf into the blank movie clip.

    Code:
    total_bytes = _root.getBytesTotal();
    loaded_bytes = _root.getBytesLoaded();
    remaining_bytes = total_bytes-loaded_bytes;
    percent_done = int((loaded_bytes/total_bytes)*100);
    bar.gotoAndStop(percent_done);
    ifFrameLoaded ("Scene 2", 30) {	gotoAndPlay ("Scene 2", 1);}
    What needs to be modified?
    Thanks

  9. #9
    Senior Member
    Join Date
    Dec 2001
    Posts
    156
    The code that OldNewbie gave:

    if(_framesloaded >= _totalframes){
    gotoAndPlay("Scene 1", 1);
    }

    That worked! Yes! Thank you! thank you! thank you!

    Just wondering though... why did Macromedia change the code necessary to acomplish the "looping preloader?" It seems more complex than the way it used to be. Maybe it opens up more abilities in other areas. I don't know.

  10. #10
    Senior Member
    Join Date
    May 2000
    Posts
    185
    ok, here's the code that I have. It seems to be working but my loader bar is not moving. it starts out already at the 100% mark and the percentage is not increasing. It stays at 0.

    This is what's on frame one of my external movie clip
    Code:
    percentSetup = ((_root.bytesLoaded / _root.bytesTotal) * 100);
    percentage = int(percentSetup)
    setProperty ("_root.LoaderBar", _xscale, percentSetup);
    if (_root.getBytesLoaded() >= _root.getBytesTotal()){ 
    gotoAndPlay(1); 
    }
    Somebody's gotta know what's wrong here. I just can't figure it out.


  11. #11
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Is your bar already scaled up to start with?

    This is usually just a thin bar to start off, and scaling it with the loaded percentage scales that bar up to a "100" %, that is 100 times the bar's width.

  12. #12
    Senior Member
    Join Date
    May 2000
    Posts
    185
    It is scaled to 100%. I went and scaled it all the way down to a very thin line. Now the thing just sits there at that point and doesn't even move and the percentage box stays at 0.

    Do you think you can work with that And I'm using the exact code that I posted earlier. I think it may be something with the code but I don't know what it is.

    Thanks for your help. Hope you can help me figure this one out.

  13. #13
    Junior Member
    Join Date
    Oct 2001
    Posts
    8

    bar expansion

    Have you definatly got a shape tween between a thin bar on frame 1 and a thick bar on frame 100?? (Im not being patronising... its the only thing i can think of if the actionscript is exactly the same)Also have you got the stop action on the bar movieclip?

  14. #14
    Junior Member
    Join Date
    Aug 2000
    Posts
    15
    Just a quick thought, seems to work fine for me.
    where 'bar' is the scalable preload and 'percentage' is the display value.

    Cheers Dan



    this.onEnterFrame = function() {
    total = getBytesTotal();
    loaded = getBytesLoaded();
    percent = Math.round(loaded/total*100);
    this.bar._xscale = percent;
    percentage = percent+"%";
    if (percent==100) {
    gotoAndPlay("startmovie");
    }
    }



    You may also want to set an initial _xscale ie.

    // Set the initial width of the loading bar
    this.bar._xscale = 1;


    [Edited by doxnam on 04-05-2002 at 04:17 AM]

  15. #15
    Senior Member
    Join Date
    Dec 2001
    Posts
    156
    Hi guys,
    sorry to change the subject back to the simple preloder. I was trying to use the script:

    if(_framesloaded >= _totalframes){
    gotoAndPlay("Scene 1", 1);
    }

    which worked really well in the movie I made yesterday, to do a preloader in a different one I'm working on today. Except this time every time I try to play the .swf file or test the movie I get this error message:

    "A script in this movie is causing Flash Player to run slowly, if it continues to run, your computer may become unreponsive. Do you want to abort the script?"

    When I take the script out it runs fine.

  16. #16
    Senior Member
    Join Date
    May 2000
    Posts
    185
    doxnam, that code worked perfect the very first time. Thanks for the help.

  17. #17
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    the problem with that onEnterFrame is that it will keep executing until that movie is removed or deleted.
    check it with this:
    Code:
    this.onEnterFrame = function() {
        trace("onEnterFrame is still running"); 
        total = getBytesTotal(); 
        loaded = getBytesLoaded(); 
        percent = Math.round(loaded/total*100); 
        this.bar._xscale = percent; 
        percentage = percent+"%"; 
        if (percent==100) { 
            gotoAndPlay("startmovie"); 
        } 
    }
    the 2 frame loop is a good way around this, or you could make a new movieclip for the preloader, deleting it after it's finished its job:
    Code:
    _root.createEmptyMovieClip("loader", ++highestLevel);
    _root.loader.onEnterFrame = function(){
        var l = movieToLoad.getBytesLoaded();
        var t = movieToLoad.getBytesTotal();
        var p = Math.round((l/t)*100);
        if ( l == t ) {
            movieToLoad.gotoAndPlay("start");
            this.unloadMovie();
        }
    }

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