import mx.utils.Base64Encoder;
import mx.utils.Base64Decoder;
// Compress a ByteArray into a Base64 String.
function compress(bytes:ByteArray):String {
var enc:Base64Encoder = new Base64Encoder();
enc.encodeBytes(bytes);
return enc.drain().split("\n").join("");
}
// Uncompress a Base64 String into a ByteArray.
function uncompress(str:String):ByteArray {
var dec:Base64Decoder = new Base64Decoder();
dec.decode(str);
var newByteArr:ByteArray=dec.toByteArray();
return newByteArr;
}