A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [MX04] Question about preloaders

Hybrid View

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    13

    [MX04] Question about preloaders

    When you call _root.getBytesTotal() does that return absolutely all the bytes in the whole thing?

    im quite new to this so sorry if im not making sense.
    say i had a separate movie clip on one frame, will it then look inside that movie clip and count all the bytes inside that or does it only count the bytes on the first timeline thing.

    if you get that please help, i dont think my preloader is loading everything even though getBytesLoaded() returns 100%

  2. #2
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    It should do, yes.

    Looking over the adobe help:

    MovieClip.getBytesTotal

    Availability
    Flash Player 5.

    Usage

    myMovieClip .getBytesTotal()

    Parameters
    None.

    Returns
    An integer indicating the total size, in bytes, of the specified MovieClip object.

    Description
    Method; returns the size, in bytes, of the specified MovieClip object. For movie clips that are external (the root movie or a movie clip that is being loaded into a target or a level), the return value is the size of the SWF file.

    See also
    MovieClip.getBytesLoaded
    If you paste here all of your preloader code, or even the FLA i will have a look where you are going wrong if you like.

    It should look something like this:
    PHP Code:
    (frame 1)
    if (
    _root.getBytesLoaded() == _root.getBytesTotal()) {
        
    //Fully loaded code here
            
    gotoAndPlay("start"); //for example
    } else {
        
    play();
        
    loadedprogress int((getBytesLoaded())/1024)+" / "+int((getBytesTotal())/1024);

    (
    frame 2)
    gotoAndPlay(1);


  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    13

    hmm

    Ok i uploaded the fla to my site:
    rocketeermusic.co.uk/flashstuff/basic-full-flash-site.fla
    (do you need all the image files when i give you the fla??)

    And here is a link to te swf in action:
    rocketeermusic.co.uk/flashstuff/example.html
    if you notice when it loads up at the beginning the box in the middle takes a long time to load even though at that time _root.getBytesLoaded() = 100%, this is what is worrying me as the box is a separate MovieClip.

    Also another question, MovieClip doesnt really make sense to me, why is it called MovieClip when its not a movie clip lol.

  4. #4
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    Cant use Spaces in Code name so it has to be MovieClip or Movie_Clip I guess they went with the first as it is 1 character less.


    Anyway, i have put in a preloader that works for you.
    Some problems with why it wasnt working. You cant gotoAndPlay() the frame you are currently on.
    Also i dont think gotoAndFrame(nextFrame) works. I think you just use nextFrame() to go to the next frame. (or of course simply play() )

    Anyway what i did is make a preloaderclip that sits in the frames of your preloader animation, it checks the percentage and goes to the properframe.

    They preloader looked like it was loading but it actually was just playing as fast as it could handle (gave the illusion of preloading) The reason it took so long to load the last part is by the time it got there it was only 50% loaded.

    Anyway, here's the file.

    http://www.xyis.net/temp/basic-full-...site-turbs.fla

  5. #5
    Junior Member
    Join Date
    Apr 2008
    Posts
    13
    thanks for the fla but it said unexpected ile format when i tried to open it??

  6. #6
    Has Returned
    Join Date
    Mar 2001
    Posts
    269
    oh yeah, wish i could save as mx.

    I can give you some code to add.
    put stops on each of the script layers frames up to frame 16

    Then make a new movieclip on the "main" layer.
    Put a blank keyframe on frame 17. (this should mean the MC will not be on any frame after 16)

    add this code to the MC
    PHP Code:
    onClipEvent (enterFrame) {
        var 
    percent int((_root.getBytesLoaded()/_root.getBytesTotal())*100);
        if (
    percent<=6) {
            
    _root.gotoAndStop(1);
        } else if (
    percent<=12) {
            
    _root.gotoAndStop(2);
        } else if (
    percent<=18) {
            
    _root.gotoAndStop(3);
        } else if (
    percent<=24) {
            
    _root.gotoAndStop(4);
        } else if (
    percent<=30) {
            
    _root.gotoAndStop(5);
        } else if (
    percent<=36) {
            
    _root.gotoAndStop(6);
        } else if (
    percent<=42) {
            
    _root.gotoAndStop(7);
        } else if (
    percent<=48) {
            
    _root.gotoAndStop(8);
        } else if (
    percent<=54) {
            
    _root.gotoAndStop(9);
        } else if (
    percent<=60) {
            
    _root.gotoAndStop(10);
        } else if (
    percent<=66) {
            
    _root.gotoAndStop(11);
        } else if (
    percent<=72) {
            
    _root.gotoAndStop(12);
        } else if (
    percent<=78) {
            
    _root.gotoAndStop(13);
        } else if (
    percent<=84) {
            
    _root.gotoAndStop(14);
        } else if (
    percent<=90) {
            
    _root.gotoAndStop(15);
        } else if (
    percent<=99) {
            
    _root.gotoAndStop(16);
        } else if (
    percent == 100) {
            
    _root.gotoAndPlay(17);
        }


    That should then work.

  7. #7
    Junior Member
    Join Date
    Apr 2008
    Posts
    13
    ok i think iv done this wrong.
    what do you mean by make a new movieclip on the "main" layer?
    which frame?

    i tried making a little rectangle on the first frame, converting that to a movie clip and then puting the actionscript on the first frame of the movie clip but that doesnt work. It doesnt even read the actionscript!

    sorry if im being a noob

  8. #8
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    @ Turbs, Ohh my sweet Lord, ever though of using something like this gotoAndStop(int((_root.getBytesLoaded()/_root.getBytesTotal())*100))) ???



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  9. #9
    Junior Member
    Join Date
    Apr 2008
    Posts
    13
    there arent 100 frames

  10. #10
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    And what's stopping you to make 100 frames ? You can extend frames to whatever length your want... If not, then you could try his "tons of if" approach or try sitting down and coming up with a mathematic formula that could help shorten the code.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  11. #11
    Junior Member
    Join Date
    Apr 2008
    Posts
    13
    onClipEvent (enterFrame) {
    var percent = int((_root.getBytesLoaded()/_root.getBytesTotal())*100);
    if(percent < 100){
    _root.gotoAndStop(int(percent/6));
    }else if (percent == 100) {
    _root.gotoAndPlay(17);
    }
    }

    hmmm this should work, but where do i put it!

  12. #12
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Since it's a "clipEvent" you need to place it on a movie clip or a button ( i'd recommend a movie clip ).



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  13. #13
    Junior Member
    Join Date
    Apr 2008
    Posts
    13
    ok iv done that but it doesnt seem to be running the movieclip.
    its placed on the first frame and to debug i put trace("hello") but nothing comes up when i test it.

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