Copy link to clipboard
Copied
Hi,
I am creating a simple preloader using Flash Components. The preloader displays the information about how much content has been loaded (in bytes and %). Here is the extract from the code:
function progressHandler(e:ProgressEvent):void
{
var percent:int = loadWindow.percentLoaded;
progress_txt.text = String(loadWindow.bytesLoaded) + " of " + String(loadWindow.bytesTotal) + " bytes" + " \n " + " (" + percent + " % loaded);
}
How can I change the information being displayed from bytes to kB?
divide bytes by 1024 (and you'll probably want to round):
function progressHandler(e:ProgressEvent):void
{
var percent:int = loadWindow.percentLoaded;
progress_txt.text = String(Math.round(loadWindow.bytesLoaded/1024)) + " of " + String(Math.round(loadWindow.bytesTotal/1024)) + " kB" + " \n " + " (" + percent + " % loaded);
}
Copy link to clipboard
Copied
divide bytes by 1024 (and you'll probably want to round):
function progressHandler(e:ProgressEvent):void
{
var percent:int = loadWindow.percentLoaded;
progress_txt.text = String(Math.round(loadWindow.bytesLoaded/1024)) + " of " + String(Math.round(loadWindow.bytesTotal/1024)) + " kB" + " \n " + " (" + percent + " % loaded);
}
Copy link to clipboard
Copied
It worked! Thanks!
Copy link to clipboard
Copied
you're welcome.