private static byte[] SwfEncodeU32(ulong value)
{
byte[] result = new byte[SwfEncodedSizeOf(value)]; // allocate a byte array to save the encoded values
for (int i = 0; i < result.Length - 1; i++) // for each byte of the encoded value
result[i] = (byte)(128 + ((value >> (i * 7)) & 127)); // the msb(128) must be set but it is part of the value
result[result.Length - 1] = (byte)((value >> ((result.Length - 1) * 7)) & 255); // the last byte contains 8 bit of the value
return result;
}