royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harbs <harbs.li...@gmail.com>
Subject Re: BinaryData and odd bytes
Date Tue, 19 Jun 2018 18:26:55 GMT
Yes. But you can convert from one TypedArray to another. That’s how the class handles reading
multi-byte data.

The single underlying ArrayBuffer can be accessed by different TypedArrays.

> On Jun 19, 2018, at 8:25 PM, Alex Harui <aharui@adobe.com.INVALID> wrote:
> 
> Isn't ByteArray mapped to UInt8Array?
> 
> On 6/19/18, 10:07 AM, "Harbs" <harbs.lists@gmail.com> wrote:
> 
>    BinaryData uses TypedArrays to read data. It seems that if the ArrayBuffer does not
divide evenly into the target TypedArray, you get a runtime error.
> 
>    For example:
> 
>    readShort() works like this:
>    var ret:int = new Int16Array(ba, _position, 1)[0];
> 
>    If _position is not divisible by 2 (i.e. an odd number), this causes a RTE.
> 
>    readInt() has a similar problem that _position needs to be divisible by 4, etc.
> 
>    Am I correct that Flash’s ByteArray works correctly in this situation? We can use
DataViews to solve the problem or we can read the bytes directly.
> 
>    Thanks,
>    Harbs
> 


Mime
View raw message