dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Whatz with this preloader

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Location
    Latvia
    Posts
    104

    please help, I'm CONFUSED

    Ok, so the story is like this- When there were those days when Flash5 was the ultimate tool I made preloaders with the "ifFramesLoaded" action. Now I have FlashMX and Macromedia tells me that my favourite action is "deprecated". So I'm told to get use to : "getBytesTotal" and "getBytesLoaded". I think- wow it must be better. So I look at some tutorials how to use those actions and off I go. I now have this code
    loadedbytes = getBytesLoaded();
    totalbytes = getBytesTotal();
    loadedkbytes = Math.ceil(loadedbytes/1000);
    totalkbytes = Math.ceil(totalbytes/1000);
    if (loadedbytes == totalbytes) {
    nextScene();
    }
    frame = int(loadedbytes/(totalbytes/100));
    tellTarget (_root.loader) {
    gotoAndStop (_root.frame);
    }
    and.............nothing works

    When my movie loads it doesn't see the preloader and skips auto to the next scene where my main movie is and loads it with no preloader.

    What is wrong? Is there smthing different in Flash MX

    ---->(oh and btw, how can I rename scenes?)

    Thanx in advance!

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Forget that code you posted and consider this:

    Open up your project and scrap whatever preloading code you have in there.
    Next open up the Scene panel (under Window), by the way that's where you can rename scenes and/or delete them. Insert a new scene (under Insert), name it preload, and make sure it's the first scene in the scene order. I'll presume you haven't change your first scene's name, and that it's still called Scene 1. If you have already renamed it, then use that name instead whenever you see Scene 1 in the following. So if preload is located under Scene 1, then drag it on top of Scene 1 while holding down the mouse button in the Scene panel.

    Next goto editing mode of this new preload scene.
    Rename the layer actions.
    Add 3 keyframes, and the following scripts to each frame:

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

    Frame 1:

    if (_root.getBytesLoaded() >= _root.getBytesTotal()){
    gotoAndPlay("Scene 1", 1);
    }
    // This is only to avoid seeing a flash frame of the preloader
    // on a refresh or subsequent visits to the site.

    Frame 2:

    if (_root.getBytesLoaded() >= _root.getBytesTotal()){
    gotoAndPlay("Scene 1", 1);
    }
    // Here you would add textfields scripts if you wanted the
    // preloader to actually display bytes loaded or percentage
    // of the movie loaded or still left to be loaded, for
    // example. But for now just leave it as is.

    Frame 3:

    gotoAndPlay(2);

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

    Now last, insert a new layer, and insert a keyframe on frame 2. This is where you should set your textfields and/or animated movie clips, so that they cover frames 2 & 3, but again making sure frame 1 of that layer stays blank. This is important so that you don't get that flash frame as I said earlier. For now simply type the static text "LOADING..."

    Test your movie, and to see the preloader in action, while testing under View, select Show Streaming.

    When you get this working, we can then get you to add a little more sophistication to your preloader, and it can all be done in those 3 basic frames.

    Please note that although this preloader would still be working, it will not show up when it should (in Flash MX), if your using Linkage (Export on first frame for Actionscript), in your movie... But that's another question.
    Doubt you're using components, so that shouldn't be a problem for ya!

  3. #3
    Senior Member
    Join Date
    Mar 2002
    Location
    Latvia
    Posts
    104
    Actually I'm using a scroll bar component What is wrong with it?

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Guess you'll then have to resort to one of the methods exposed in this thread:

    http://board.flashkit.com/board/show...hreadid=299884

  5. #5
    Senior Member
    Join Date
    Mar 2002
    Location
    Latvia
    Posts
    104
    Thanx for the help. I'll have a look.

  6. #6
    Senior Member
    Join Date
    Mar 2002
    Location
    Latvia
    Posts
    104

    :frustrated:

    please look what is the problem is this. I am now in a total mess and do not understand what is right and what is not.
    http://sanctuary.yo.lv/preprob.fla

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    IMHO, it's not quite how a preloader should be done, but for the moment, just get rid of your tellTarget action on frame 2... And replace it with the bold line... It should work!

    if (_root.getBytesLoaded()>=_root.getBytesTotal()) {
    gotoAndPlay("Scene 1", 21);
    }
    loadedbytes = getBytesLoaded();
    totalbytes = getBytesTotal();
    loadedkbytes = Math.ceil(loadedbytes/1000);
    totalkbytes = Math.ceil(totalbytes/1000);
    frame = int(loadedbytes/(totalbytes/100));
    _root.loader.gotoAndStop(frame);
    //tellTarget (_root.loader) {
    // gotoAndStop(_root.frame);
    //}

    If I have a few minutes, I'll correct your .fla, and send it back to you if you e-mail me your address at oldnewbie@hotmail.com.

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    In fact, you don't have a loader movie clip, so scrap my line also.

    if (_root.getBytesLoaded()>=_root.getBytesTotal()) {
    gotoAndPlay("Scene 1", 21);
    }
    loadedbytes = getBytesLoaded();
    totalbytes = getBytesTotal();
    loadedkbytes = Math.ceil(loadedbytes/1000);
    totalkbytes = Math.ceil(totalbytes/1000);
    frame = int(loadedbytes/(totalbytes/100));

    Also add a stop(); action on your frame 21 of scene 1, otherwise this thing will loop back to the preloader, once loaded.

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