0
Here we are first checking the value of bytes and if its less that zero or not a number returns null.
Otherwise we are calculating,
1024 Bytes = 1 KB.
1024 KB = 1 MB
/**
* Calculates the File size
*
* @param bytes Loaded bytes or file size in bytes
* @return converted bytes to String.
*/
function fileSize( bytes : Number ) : String
{
if(bytes<0 number =" Number(bytes/1024);" string =" Math.round(fileSize)">0?(fileSize>1024?(fileSize/1024).toFixed(2)+"MB":((fileSize.toFixed(2))+"KB")):(fileSize*1024)+"Bytes" ;
return FileSize_str;
}
Download Source file
Posted on 11:15 PM by Author and filed under
ActionScript 2.0,
ActionScript 3.0
The function calculates values from Bytes to KB or MB.Here we are first checking the value of bytes and if its less that zero or not a number returns null.
Otherwise we are calculating,
1024 Bytes = 1 KB.
1024 KB = 1 MB
/**
* Calculates the File size
*
* @param bytes Loaded bytes or file size in bytes
* @return converted bytes to String.
*/
function fileSize( bytes : Number ) : String
{
if(bytes<0 number =" Number(bytes/1024);" string =" Math.round(fileSize)">0?(fileSize>1024?(fileSize/1024).toFixed(2)+"MB":((fileSize.toFixed(2))+"KB")):(fileSize*1024)+"Bytes" ;
return FileSize_str;
}
Download Source file
Post a Comment