A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: % follow preload

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    I edited the prior post - take a look.

    Here's the version I made after looking at your movie. I changed the width of the bar to match the clip width in your movie.

    code:

    getRatio = this.getBytesLoaded()/this.getBytesTotal();
    this.loadBar._width = getRatio*234;
    loadText._x = loadBar._x + loadBar._width;
    loadText.text = Math.floor(getRatio*100) + '%';
    if (getRatio == 1) {
    this.gotoAndPlay(3);
    }



    This is a good example of why I like ratios better than percentages. If you had computed the percentage right away, the script would have read:

    code:

    getPercent = Math.round(this.getBytesLoaded()*100/this.getBytesTotal());
    this.loadBar._width = (getPercent/100)*234;
    loadText._x = loadBar._x + loadBar._width;
    loadText.text = getPercent + '%';
    if (getPercent == 100) {
    this.gotoAndPlay(3);
    }



    Personally I don't like this as much because every time you want to use the percentage for something, the math is more complicated. The only thing it simplifies is displaying the text for human consumption (something which I personally don't think is necessary - the scroll bar itself speaks volumes).
    Last edited by jbum; 05-28-2004 at 01:48 AM.

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