A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 53 of 53

Thread: Preloader Explained

  1. #41
    Member
    Join Date
    Aug 2004
    Location
    houston,Tx
    Posts
    45
    this has been a very informative post. thanx. it solved a lot of my problems.

  2. #42
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554
    Thanks just glad to help
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

  3. #43
    Member
    Join Date
    Mar 2001
    Location
    Earth
    Posts
    39
    What do you to make it move one once it is all done loading?
    What doesn't hurt me, was only meant to annoy me!

  4. #44
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554
    where the if statement checks if the percent loaded is 100 and if it is it says _root.play(); which makes the main timeline playhead move
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

  5. #45
    SOPRANO
    Join Date
    Sep 2000
    Location
    Mexique
    Posts
    94
    Originally posted by jarsworld
    What do you to make it move one once it is all done loading?

    I want the loader to "appear" with an alpha effect and then when the loader finish to dissapear or move away, I tried it with a MC but doesnt work.


  6. #46
    Senior Member
    Join Date
    Aug 2005
    Posts
    238

    I dont see the attached .fla

    for some reason i dont see the attached .fla Could you repost it please?

  7. #47
    Junior Member
    Join Date
    Jul 2005
    Posts
    16
    Me either! Please post again!

  8. #48
    Member
    Join Date
    Jan 2006
    Posts
    92
    i concur... Please reattach the FLA if possible! tahnks

  9. #49
    Junior Member
    Join Date
    Aug 2006
    Posts
    12
    Quote Originally Posted by joejoe2288
    Ok i have seen about 5000 posts asking about how to make a preloader
    and how it works. Within this post i will describe how the preloader
    works, and how to use it.A preloader is something that holds the
    movies playhead at the first frame or specified frame until the
    total file size of the movie is loaded, if a preloader is not used
    in your movie, the movie can become choopy and unclear whihc can
    ruin the entire movie, making a preloader essential to understand.
    First off download the attached fla. Once you have it opened as you
    can see the entire preloader is inside 1 movieclip making this a
    very simple object to use. In your preloader you can have any amount
    of animations you like, but keep in mind that the preloader can't
    preload its self, so the preloader must be loaded before the
    preloader can start to work. You might want to keep the preloader
    size under 10 kb. Next open the preloader movieclip by double
    clicking on the preloader and you will see multiple layers with
    various things on them. We are going in order from top layer to
    bottom layer. In the first layer is the actions
    code:

    _root.stop();
    PercentLoaded = _root.getBytesLoaded()/_root.getBytesTotal()*100;
    if (PercentLoaded != 100) {
    setProperty(bar, _xscale, PercentLoaded);
    } else {
    _root.play();
    }
    percentDone = Math.ceil(PercentLoaded)+"%";
    bytesloaded = (_root.getBytesLoaded()/1000);
    bytestotal = (_root.getBytesTotal()/1000);
    bytes_loaded = Math.ceil(bytesloaded)+"kb";
    bytes_total = Math.ceil(bytestotal)+"kb";


    I will describe these as we get to each part. In the second layer is
    just an outline of the load bar so you can see how far the loading
    has left(this part is optional).In the third layer is the loadbar
    it's self which is what changes size as you can see by these actions
    code:

    _root.stop();
    PercentLoaded = _root.getBytesLoaded()/_root.getBytesTotal()*100;
    if (PercentLoaded != 100) {
    setProperty(bar, _xscale, PercentLoaded);
    } else {
    _root.play();
    }


    _root.stop(); stops the main playhead as i forgot to mention before
    the only content that should be on the first frame of oyu movie
    should be the preloader everything is at least 1 frame later. So
    when the playhead stops on frame 1 the movieclip on frame one(the
    preloader) loops and inside this movieclip is two frames which loop
    continually. On the second frame on the actions layer is
    code:

    gotoAndPlay(1);


    what this effectively does is sends the playhead that is inside the
    movieclip back to frame one and recalls the actions in that layer
    therefore updating all the actions every 2 frames. the PercentLoaded
    is a variable that is defined by the total amount of bytes in the
    swf, that is if oyu say _root.getBytesLoaded() because if you say
    getBytesLoaded you are basically saying get the bytes for just this
    movieclip and then it will only load hte preloader and the rest of
    the movie will still be unloaded. When you say _root.getBytesLoaded
    ()/_root.getBytesTotal() you are creating a ratio that will always
    be less than or equal to 1 which is how you find the percentage
    loaded. Lets say you have a movie that is 100kb and 25kb of it is
    loaded. The PercentLoaded would be .25 and if we want the actaul
    percent all of us mathmaticians know that you have to mulitply it by
    100 to get the actual percent, hence you have the PercentLoaded. Now
    in the next line of scripting where it says
    code:

    if (PercentLoaded != 100) {


    this is an if statement saying if the PercentLoaded variable is NOT
    equal to 100 then do the following actions. The following actions are
    code:

    setProperty(bar, _xscale, PercentLoaded);


    this sets the propertie of the loadbar which has an instance
    (reference name) of bar so we set the property of the _xscale of the
    bar which is 100 if it is equal to the regular _xscale making this a
    handy tool to use since it can be equivilant to the PercentLoaded.
    We could also say these actions in the one aboves place and it would
    do the same thing
    code:

    _root.preloader.bar._xscale = PercentLoaded;


    and now to the next line where it says
    code:

    }else{


    this is basically equivilant to saying if the if statement
    code:

    if (PercentLoaded != 100) {


    is not true then do the following actions which are
    code:

    _root.play();


    this is basically the opposite of the _root.stop(); action. What the
    _root.play(); action does is starts the main timeline playhead again
    so the movie continues to play. So here is what these actions
    code:

    } else {
    _root.play();
    }


    mean in regular terms: if the PercentLoaded is equal to 100 then
    play the main timeline. Pheww now to layer 4. In layer four is the
    display of the percent done. The way we display variables is create
    a dynamic text box and give it a var which you can relate so that it
    will display whatever you want it to say in actionscripting. In this
    case you could use the PercentLoaded varible like so
    code:

    percentDone = Math.ceil(PercentLoaded)+"%";


    what Math.ceil() does is it basically rounds the number following it
    to a whole number this also can be done with the Math.round()
    function. So we are rounding the PercentLoaded so that if the actual
    PercentLoaded was 54.67895634 it will display 55. When i say +"%" i
    am indicating that you need to add the following to the display.
    This just happens to be in quotations meaning that you add the
    character to that text field instead of a variable. Now on to layer
    5. In layer 5 is a dynamic text field that displays the kb loaded
    using these actions
    code:
     
    bytesloaded = (_root.getBytesLoaded()/1000);
    //this just assigns a variable the value of the bytes loaded *1000
    //since 1 kb is 1000 bytes
    bytes_loaded = Math.ceil(bytesloaded)+"kb";
    //the line above rounds the bytesloaded and adds the charaters kb to
    //it and assigns the text field bytes_loaded that value


    Also in layer 5 is just a regular text field with the value of "of"
    showing that this amount of kb is loaded out of this other amount of
    kb. And lastly in that layer is the other text field displaying the
    totalbytes
    code:

    bytestotal = (_root.getBytesTotal()/1000);
    //here we assign this variable getting the bytes of the total swf
    //which will not change but needs to be assigned
    bytes_total = Math.ceil(bytestotal)+"kb";
    //and the line above assigns the text field bytes_total the value
    //above


    In the last and final layer is a simple animation that loops whihc
    can be removed or changed and will not affect the loading process.
    I hope this tutorial has helped you and if you have any questions
    feel free to post back and ask. If you feel something should be
    added, please post as well and i will edit it.
    Thanks,
    Joe
    Great code, yet do you know why I would have a problem with a preloader working when it is being loaded into a scrollpane?
    The swf loads great with the preloader starting almost instantly when you access it directly from the server, yet if I try to load it into a scrollpane, the end result is I wind up looking at a blank scrollpane until 95% of the entire file has loaded.
    This is a killer as people will not just sit there for 1 or 2 minutes waiting...
    Any clues?

  10. #50
    Member
    Join Date
    Jul 2006
    Posts
    93

    how to put FLV video after typing all those script??

    I followed your instruction(actionscript on first post message)
    But I don't know how to add FLV video. Is it OK to import video to library ro should I create new video symbol from library and put action script( NS stream)??
    Can you explain how to put FLV video(progressive downloaded video) and where I should put ( frame 2 or 3??)

    THank you!

  11. #51
    Wait- what now? tidenburg's Avatar
    Join Date
    Dec 2005
    Posts
    1,471
    homer6000 did you really have to quote that WHOLE post?
    "I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."

  12. #52
    The Living Legend of Fury
    Join Date
    Oct 2005
    Location
    San Antonio, TX
    Posts
    25
    Where do you download the preloader *.fla file at? I really want it cuz I need to make a Mortal Kombat preloader. I have 4 mortal kombat movies that don't have preloaders!

  13. #53
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Hey JoeJoe, kinda STOLE MY TITLE THERE! (Check my sig)....
    http://www.flashkit.com/board/showthread.php?t=661940
    ....
    Anyway, nice post, although, I'm sure unintentially the code is very similiar to mine (http://www.flashkit.com/board/showthread.php?t=661940)....

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