In the MSDN I couldn't find anything, what would help me. On a other page I found an example where a bytearray was converted into a HEX-string. I had to modify it a little, but now it works:
import flash.utils.ByteArray;
import mx.collections.ArrayCollection;
import mx.utils.UIDUtil;
public class RawTypeUtil
{
private static const hexValues:Array = [ '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];
private static const convertSequence:ArrayCollection = new ArrayCollection([ 3, 2,
1, 0, 5, 4, 7, 6, 8, 9,
10, 11, 12, 13, 14, 15 ]);
public function RawTypeUtil(lock:Class)
{
if (lock != RawTypeUtilLock)
{
throw new Error("Invalid RawTypeUtil access.");
}
}
public static function guidToHex(guid:String) : String
{
// the UIDUtil expects an uppercase uid...
guid = guid.toUpperCase();
if (!UIDUtil.isUID(guid))
{
return null;
}
var bytes:ByteArray = UIDUtil.toByteArray(guid);
var hex:String = "";
var byteArray:ArrayCollection = new ArrayCollection();
for (var i:uint = 0; i < bytes.length; i++)
{
var byte:uint = bytes.readUnsignedByte();
byteArray.addItem(byte);
}
for (var j:uint = 0; j < convertSequence.length; j++)
{
var index:uint = convertSequence.getItemAt(j) as uint;
var value:uint = byteArray.getItemAt(index) as uint;
var l:int = value / 16;
var r:int = value % 16;
hex += hexValues[l] + hexValues[r];
}
return hex;
}
}
I don't know why I have to change the order of the first 4 bytes, 5th and 6th, and 7th and 8th that the ByteArray is converted in a correct format. I hope somebody can explain that to me.