dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [CS3] [AS2] bytesTotal and bytesLoaded return a wrong size?

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Posts
    108

    [CS3] [AS2] bytesTotal and bytesLoaded return a wrong size?

    Hello there.

    I've just made a simple preloader for my site which uses the MovieClipLoader() thing, and which includes a little progress bar which will scale depending on the percentage downloaded.

    It also shows the amount of downloaded kilobytes and the total size of the file in kilobytes.

    It all works flawlessly, the bar scales accordingly, etc.

    But after looking at the numbers... I realized... the reported sizes are wrong! They seem to be of aproximately double the size of the actual file...

    The .swf file seems to be about 219 kB big in the server, as the FTP client reports (and also in my hard drive).

    However, when the preloader starts downloading it, it claims that the file is 447 kB big... why??

    It seems as if both bytesTotal and bytesLoaded were reporting around double sizes.

    This is the code I used:

    Code:
    controlPreloader.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
        kilobytes_loaded = Math.round(bytesLoaded /1024);
        kilobytes_total = Math.round(bytesTotal /1024);
        info = "Loaded " + kilobytes_loaded + " of " + kilobytes_total + " kB";
    I also tried to show them as raw bytes, without converting them to kilobytes (i.e.: without dividing them by 1024), but the result was also double size in bytes.

    Has this ever happened to anyone? Of course, it doesn't affect the performance of the site, but... well, I don't like to display wrong information to the public, lol

    Why is this happening?
    Work like you don't need the money
    Dance like nobody's watching
    Love like you've never been hurt
    **** like you're being filmed

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Try this:
    PHP Code:
    controlPreloader.onLoadProgress = function(target:MovieClip,lBytes:Number,tBytes:Number):Void {
        
    percent Math.round((lBytes/tBytes)*100);
        
    info "Loaded " + (lBytes/1024) + " of " + (tBytes/1024) + " kB ("+percent+"%)";


  3. #3
    Senior Member
    Join Date
    Sep 2003
    Posts
    108
    Erm... does exactly the same as my code? I mean, it's the same but with some variable names changed, and with the percent stored in a variable?

    I don't know if you got my question right... I am able to obtain the correct percentage because both values (bytesLoaded and bytesTotal) are wrong in the same proportion... so the percentage is alright. It's the actual value in bytes what seems to be wrong (about double of the real value).

    I just can't understand why a 219kB file is detected as a 447 one by flash... lol
    Work like you don't need the money
    Dance like nobody's watching
    Love like you've never been hurt
    **** like you're being filmed

  4. #4

  5. #5
    Senior Member
    Join Date
    Sep 2003
    Posts
    108
    You can even check it online:

    http://www.hoysesale.net

    The variable info is shown in the text field above the progress bar.

    I tried your code, then restored mine back, but the result was being exactly the same, except that you had the percentage included in the text, and that my words are in Spanish

    You can delete your temp files and re-run the site as many times as you want to see it happen.

    The preloader is only executing this code to preload the main site:

    Code:
    preloader.loadClip("index.swf", lienzo);
    And here you have the index.swf file:

    http://www.hoysesale.net/index.swf

    As you can see if you save the file to disk, it's only 218kB big, while the preloader says 446 kB.

    It's one of the strangest things I've ever seen happening in flash, lol.
    Work like you don't need the money
    Dance like nobody's watching
    Love like you've never been hurt
    **** like you're being filmed

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you are Publishing with the Compress Movie option tagged.

    decompiling reveals -
    flash 8, total frames: 1, frame rate: 30 fps, 975x610 px, compressed

    try un-tagging the Compress option and let us know the result

  7. #7
    Senior Member
    Join Date
    Sep 2003
    Posts
    108
    LOL! Didn't even know there was an option to compress movies. I tried exporting without compressing it and, in fact, its size was 446 kB.

    That's curious...

    Either:

    1. The .swf is de-compressed before actually downloading it to your PC, which I see difficult to happen, as that would mean a server-side script which I don't know about (or maybe a smart monkey who sleeps next to the servers) would be uncompressing the .swf files

    or

    2. It's actually compressed while downloading it, but the MovieClipLoader detectors report its full size... maybe to give people the feeling that their connection and/or website is actually faster than what it really is? lol.

    Anyway, interesting to know.

    Thanks a lot to both of you

    a_modified_dog: you've pretty much solved all my preloading problems between yesterday and today... so I think I don't have anything else to ask I'm begginning to think FlashKit staff pay you to stay here 24/7, lol.

    See you!
    Last edited by oVMXo; 04-28-2008 at 02:51 PM.
    Work like you don't need the money
    Dance like nobody's watching
    Love like you've never been hurt
    **** like you're being filmed

  8. #8

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    flash beast

    woof woof snarl snarl aarf aarf howl

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