A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: jpeg percentage loader (not preloader)

  1. #1
    Junior Member
    Join Date
    Sep 2003
    Posts
    14

    jpeg percentage loader (not preloader)

    The script below loads a random jpeg dynamically onto my site..

    picTotal = 18;
    // adjust per total pics, img1.jpg,...,imgN.jpg, where N=picTotal
    name1 = "img"+Math.ceil(Math.random()*picTotal)+".jpg" ;
    loadMovie(name1, _root.BG);
    // use loadMovie when loading into a target movielcip
    preloadI = setInterval(preloadF, 10);
    function preloadF() {
    if (_root.BG.getBytesLoaded()>=_root.BG.getBytesTotal ()) {
    // you must reference the target level or clip.
    _root.BG._x = 0;
    // try 0, 0 first. see if that lines up your background pics.
    _root.BG._y = 0;
    clearInterval(preloadI);
    }
    }

    how could i adapt it to show percentage of the jpeg loaded? as some jpegs take long to load and it would be nice for the viewer to see what happeneing (the jpegs are small and making them smaller would be difficult.

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Add a dynamic textfield with variable name precent..and try this.....


    tb = math.round(_root.getBytesTotal()/1024);
    lb = math.round(_root.getBytesLoaded()/1024);
    percent = math.round((lb/tb)*100);
    picTotal = 18;
    // adjust per total pics, img1.jpg,...,imgN.jpg, where N=picTotal
    name1 = "img"+Math.ceil(Math.random()*picTotal)+".jpg" ;
    loadMovie(name1, _root.BG);
    // use loadMovie when loading into a target movielcip
    preloadI = setInterval(preloadF, 10);
    function preloadF() {
    if (lb>=tb && tb>1) {
    // you must reference the target level or clip.
    _root.BG._x = 0;
    // try 0, 0 first. see if that lines up your background pics.
    _root.BG._y = 0;
    clearInterval(preloadI);
    }
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Junior Member
    Join Date
    Sep 2003
    Posts
    14

    yay

    thank you kindly!

    mk

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