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).




Reply With Quote