A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: preloader question

  1. #1
    Member
    Join Date
    Apr 2001
    Posts
    55

    preloader question

    I'm wondering how they work, exactly...

    ...is there a way for the preloader to be skipped completely if the browser in use has all the necessary data cached? I'm noticing that my preloader plays all the time, even when I know the page is cached.

    Does that make sense? I'd like to skip that scene altogether if possible, when necessary. The 10-30fr preloaders can be a real nuisancen for smooth transitions, imo..

    thanks!

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Be better if you posted your preloader code. That said if your preloader starts off with a blank keyframe with only the following script and no displays of any sort, it should work...

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

    Replace "main" with your actual main scene's name, or only use a frame label, set on the first frame of your main scene...

  3. #3
    Member
    Join Date
    Apr 2001
    Posts
    55
    Heh, that's the thing...I don't have any preloader code! Haha, I'm so new at this stuff, I had no idea how they really worked.

    I'm going to give your suggestion a try, thanks a lot!

  4. #4
    Member
    Join Date
    Apr 2001
    Posts
    55
    Works beautifully, oldnewbie. Thanks AGAIN for your outstanding support...so far, most of the tricks I've learned have been sent from you!

    peace

  5. #5
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    But that can't work on it's own! That would only really work if it preceded a preloader, and is only used to avoid seeing a flash frame of the preloader displays upon a subsequent visit to your site or upon a refresh.

    The minimum for it to really work would be to add a second frame actionscript with...

    gotoAndPlay(1);

    ... At least then, if it still doesn't display anything, it would loop until the movie was fully cached, and then have it play.

    BTW, you can't really test this that way locally, 'cause your file is on your drive and doesn't even need to preload.

  6. #6
    Member
    Join Date
    Apr 2001
    Posts
    55
    That's weird...I uploaded all the files (updated with the code you gave me) and it seemed to work fine. My cache was flushed, too.

    I added a blank frame before the preloader began, and that was were your code was placed.

    So you say I should put that 2nd frame actionscript just to be extra careful? The remote test seemed to work OK...I'll try it once more to be sure.

    thanks again

  7. #7
    Member
    Join Date
    Aug 2002
    Location
    sunny manchester, uk
    Posts
    84
    I'm trying to do the same thing; skip the preloader if the external swf has already loaded in. Heres my script:

    //
    stop(); //placed on first frame

    //Placed on the loader_mc (which is also placed on the first frame)
    onClipEvent (enterFrame) {
    loading = _parent.getBytesLoaded();
    total = _parent.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    percentage = int(percent);
    loading = int(total*.001)+" k";
    if (percent>99) {
    _parent.gotoAndStop(2);
    }
    }

  8. #8
    Member
    Join Date
    Apr 2001
    Posts
    55
    Interesting, did you get yours to work properly?

  9. #9
    Member
    Join Date
    Aug 2002
    Location
    sunny manchester, uk
    Posts
    84
    not yet I'm trying else if statements


    onClipEvent (enterFrame) {
    loading = _parent.getBytesLoaded();
    total = _parent.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    percentage = int(percent);
    loading = int(total*.001)+" k";
    if (_parent.getBytesLoaded()>=_parent.getBytesTotal() ) {
    _parent.gotoAndStop(2);
    } else if (percent>99) {
    _parent.gotoAndStop(2);
    }
    }


    but it to no avail any ideas?

  10. #10
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    I said... That would only really work if it preceded a preloader..., because you had said you had no preloader code... ...I don't have any preloader code! Haha....

    You're now saying you have some preloader code following this first frame, then it would work, as it would for gonk, if he simply added a first blank keyframe before the frame he has his preloader clip on.

    The first frame must only hold that code and nothing else, assuming you do have some preloader code following that frame. Otherwise, if the movie wasn't cached, and you didn't have any preloading code, then that line of code alone, would do nothing.

  11. #11
    Member
    Join Date
    Apr 2001
    Posts
    55
    Ah, I'm sorry...I'm kinda miscommunicating right now.

    This is what I did---

    First, I had nothing (no code) in the preloader. I followed your directions and stuck that code you gave me, placing it in a blank frame before preloader animation/load cycle begins. The only code I have after the preloader is for it to go to the next scene, frame 1.

    Sorry for the mix up, and thanks for your help!

  12. #12
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You're still miscommunicating!

    Are you saying you have no preloading code whatsoever after the line I gave you, except goto next scene? Then you're movie is never really preloading, and if you're on a fast connection, you just think it's working because it so fast. But I bet you that on a slow connection (such as the one I'm now using!), the preloader never preloads your movie, which is just streaming along.

    Give us a link!

  13. #13
    Member
    Join Date
    Apr 2001
    Posts
    55
    lol, sorry...alright this link should make things very clear

    http://www.lordcheez.com/index_new.html

    Each button on the bottom has a "preloader" (for lack of better term)

    I'm still totally new at this (my first flash page ever created) so, apologize for any confusion.

  14. #14
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Yeah! You seem to have some preloaders, although you say you have no preloading code! That I still don't uderstand. You didn't add my line on Porfolio, because I see a flash of the preloader when going back to it after I've already see it!

  15. #15
    Member
    Join Date
    Aug 2002
    Location
    sunny manchester, uk
    Posts
    84
    thanks oldNewbie

    it works although it seems to slow down the time it takes
    to get to the preloader only by half a sec or so

  16. #16
    Member
    Join Date
    Apr 2001
    Posts
    55
    Whew....I got scared for a second there, when you said I didn't have preloaders! Glad to hear I do!

    This is how i handled my preloader--- I have that "loading" animation as a movieclip playing on one layer, and on a separate layer, one frame at a time I place all the different symbols out of view. So, in essence, aside from the code you gave me, I really didn't "code" anything. Does that make sense?

    I don't know if that's an effecient way to preload, but since you are on a slow connection and saw that it worked, I'm assuming I'm on the right track?

    Thanks again! I'll fix the Portfolio one right now

  17. #17
    Member
    Join Date
    Apr 2001
    Posts
    55
    Originally posted by gonk
    thanks oldNewbie

    it works although it seems to slow down the time it takes
    to get to the preloader only by half a sec or so
    Yeah, I've seen that on mine as well...it's slower by 1/12th a frame, if you are defaulting at 12fps.

    I think it really only does this once, on the first load. Afterwards I think its skips over it.

    oldnewbie, are you *positive* we can't have anything other than the code on that first frame? A graphic or something?

  18. #18
    Member
    Join Date
    Aug 2002
    Location
    sunny manchester, uk
    Posts
    84
    its has the half sec pause because the size of the preloader scene
    has jumped from 3kb to 11kb. 8kb for to lines of code!
    I think I might remove it and handle seeing the preloader v.briefly
    its preferable to having a blank screen for half-one second

    btw is it benificial (size wise) to have the preloader in the same
    scene(only to scenes in swf, one is "preloader" other is "main"?

  19. #19
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Ok! My regular machine is up and running again! What a relief. Nothing lost!

    LordCheez... IMHO, yourmovies are never preloaded, they just stream. And my code, will skip what you call your preloader, only if the movie is cached on the user's system. Sorry!

    Gonk... Those lines of code don't add anything to the size of the .fla or the outputed .swf. The size of your first frame depends on your possible use of components, embedded fonts and/or Export on the first frame stuff, such as attached sound objects.

  20. #20
    Member
    Join Date
    Apr 2001
    Posts
    55
    oldnewbie:

    Thanks for the input. How do you suggest I make a proper preloader?

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