bytearray.writeObject
I may be biased because this is how we've done things in the past; definitely bytearrays make more sense if you don't need everything to be a string, or if there's some way to easily convert bytearray<->string.
Here's the functions I have
function BAtoString(a:ByteArray):String{
var s:String = "";
a.position = 0;
while(a.bytesAvailable){
var b:uint = a.readByte();
s += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][b%16];
b=b>>4;
s += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][b%16];
}
a.position = 0;
return s;
}
function StringtoBA(s:String):ByteArray{
var a:ByteArray = new ByteArray();
for(var i:int = 0; i<s.length; i+=2){
var b:uint = (hint(s.charAt(i))) + (hint(s.charAt(i+1))<<4);
a.writeByte(b);
}
a.position = 0;
return a;
}
function hint(s:String):uint {
switch(s){
case "0": return 0;
case "1": return 1;
case "2": return 2;
case "3": return 3;
case "4": return 4;
case "5": return 5;
case "6": return 6;
case "7": return 7;
case "8": return 8;
case "9": return 9;
case "a": return 10;
case "b": return 11;
case "c": return 12;
case "d": return 13;
case "e": return 14;
case "f": return 15;
}
trace("invalid character");
return 16;
}
also, if you're using a level sharing API, they generally will accept byteArrays.
and also, ByteArray.compress will do a nice compression on your level code to make it nice and short for sharing.
i wrote up a tutorial on this here
http://www.newgrounds.com/bbs/topic/1107353