A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help figuring out a progress bar value

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Posts
    263

    Help figuring out a progress bar value

    Hi ,

    I have the progress bar that takes numbers from 0 to 1 to set it's value.

    I have 150 pictures that I am loading, after each one is loaded I increment a variable numPicsLoaded.

    It works out fine if I have exactly 100 pictures, because of the 0 to 1 value.

    I was wondering if anyone knew the math to do this, with 150 pics essentially it sets the progress bar value to 1.5 which messes the bar up.
    numPicsLoaded=0;
    I increment this after each load;

    In the timer function{
    percentDone = (numPicsLoaded);
    progressBar.setValue(percentDone*0.01);
    }

    Like I said it works great with 100 pictures well because when numPicsLoaded =100 the setValue would equal 1.0.

    Thanks
    jamesloacher

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Assuming you are just wanting to figure out the percent loaded of your images this would be the math in a nutshell:
    PHP Code:
    var totalLoaded 25;
    var 
    totalPics 150;

    var 
    percLoaded Math.floor((totalLoaded totalPics) * 100);

    trace(percLoaded "%"); 

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