# Preloader tweaking-Math.round problem

**URL:** <https://forum.kirupa.com/t/preloader-tweaking-math-round-problem/102823>\
**Category:** Uncategorized\
**Created:** [February 27, 2004, 10:50am UTC](https://forum.kirupa.com/t/preloader-tweaking-math-round-problem/102823 "2004-02-27T10:50:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ubik](https://avatars.discourse-cdn.com/v4/letter/u/b38774/32.png) [@Ubik](https://forum.kirupa.com/u/Ubik)\
**Post date:** [February 27, 2004, 10:50am UTC](https://forum.kirupa.com/t/preloader-tweaking-math-round-problem/102823/1 "2004-02-27T10:50:37Z")

</div>

here’s my preloader,  
I followed a tutorial from [actionscript.org](http://www.actionscript.org/tutorials/advanced/flash_MX_loader/index.shtml) , the tricky part is that i wanted to change the Kb to a % display and it’s messing up.

Here’s the previous code [AS]lastFrame = 1;

function loadedIndicatorFrame() {  
var newFrame = int((\_parent.getBytesLoaded() / \_parent.getBytesTotal()) \* 65) + 2;  
if (newFrame - lastFrame \> 4) { //too far  
lastFrame += 4;  
loadedText = int(\_parent.getBytesTotal() / 1024 \* (lastFrame - 2) / 65) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
} else if (newFrame - lastFrame \> 0) { //normal move  
lastFrame++;  
loadedText = int(\_parent.getBytesLoaded() / 1024) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
} else { //update the text only  
loadedText = int(\_parent.getBytesLoaded() / 1024) + "kb of " + int(\_parent.getBytesTotal() / 1024) + “kb”;  
}  
return lastFrame;  
}  
[/AS]

And here’s mine[AS]lastFrame = 1;

function loadedIndicatorFrame() {  
var newFrame = Math.round(\_parent.getBytesLoaded())/Math.round(\_parent.getBytesTotal()) \* 52 + 2;  
if (newFrame - lastFrame \> 4) { //too far  
lastFrame += 4;  
loadedText = Math.round(\_parent.getBytesLoaded())/Math.round(\_parent.getBytesTotal())\*100 + “%”;  
} else if (newFrame - lastFrame \> 0) { //normal move  
lastFrame++;  
loadedText = Math.round(\_parent.getBytesLoaded())/Math.round(\_parent.getBytesTotal())\*100 + “%”;  
} else { //update the text only  
loadedText = Math.round(\_parent.getBytesLoaded())/Math.round(\_parent.getBytesTotal())\*100 + “%”;  
}  
return lastFrame;[/AS]  
I post the fla, maybe someone can point me to what’s wrong :h:  
Thanks  
Ubik
