In the following code:
var bytes:ByteArray = new ByteArray();
var i:int = -1;
var j:int;
bytes[0] = i; // bytes[0] = -1 == 0xff
j = bytes[0]; // j == 255;
The int j ends up with value 255, rather than -1. I can't seem to find a document defining how indexed access to a ByteArray is supposed to be sign extended - can I reliably assume this behavior, or should I take steps to truncate such values to 8 bit quantities? I'm porting a bunch of code from Java and would prefer to use the indexed access rather that the readByte() etc methods.