Ubik
February 27th, 2004, 05:50 AM
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 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;
}
And here's minelastFrame = 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;
I post the fla, maybe someone can point me to what's wrong :h:
Thanks
Ubik
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 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;
}
And here's minelastFrame = 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;
I post the fla, maybe someone can point me to what's wrong :h:
Thanks
Ubik