日期:2013-07-08  浏览次数:20775 次

通方法是用URLLoader,指定 loader.dataFormat = URLLoaderDataFormat.BINARY; 即可

下面是啊菜的方法,通过解析ByteArray,以下方法在获取embed资源的时候特有用:
调用方法:
//获取的值等同用urlloader的binary值
private function getFileBinary(bytes:ByteArray):Array
{
var pos:int = bytes.position;
bytes.position = 0;
var resultArray:Array = new Array();
while (bytes.bytesAvailable >=  {
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
resultArray.push(bytes.readUnsignedByte());
//resultArray.push(“”);
}
while (bytes.bytesAvailable>1) {
resultArray.push(bytes.readUnsignedByte());
}
if (bytes.bytesAvailable) {
resultArray.push(bytes.readUnsignedByte());
}
bytes.position = pos;
return resultArray;
}
获得二进制值为:
private function getHex(n:uint):String {
return n <= 0xF?”0″ + n.toString(2):n.toString(2);
}