Convert Little-endian ByteArray to Big-endian in AS3

大憨熊 提交于 2019-12-02 10:05:36

A while back I asked about this on the Adobe Forums.

The Flash VM itself is Little Endian, as is code running in Alchemy. For reasons that are unclear, many Flash APIs return bytes as Big Endian. How bizarre. (Perhaps this is a legacy API thing from the Macromedia days. Who knows?)

Setting ByteArray.endian does not change the bytes stored in the ByteArray. It affects the way that readXXX/writeXXX works (that is, they will flip the bytes as they're read/written).

However, since your Alchemy code is looking at the bytes directly (ie, not using the ByteArray methods), it has to handle the flipping manually. Note that this is true for incoming bytes as well outgoing bytes.

Some more info about flipping byte order is here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!