private static ulong SwfDecodeU32(byte[] data)
{
ulong result = 0;
for (int i = 0; i < data.Length - 1; i++) // for each byte of the encoded value
result = result + (((ulong)data[i] & 127) << (i * 7)); // seven bit are added to the result
result += (ulong)data[data.Length - 1] << ((data.Length - 1) * 7); // except the last byte which contains eight bits
return result; // of the result
}