Float32Array broken on Flash

While playing with Flash, I’ve noticed that array access on a Float32Array (using square brackets) always returns NaN. Using getFloat32 with an index works fine. I’m not sure if this is a Lime bug or a Haxe bug. Does anyone else see this behaviour?

I should mention I’m using Lime Next without OpenFL.

This also impacts on transforming a Vector4 with a Matrix4. The result is a vector with NaN for all of its values.

Thanks for bringing this up

I realize that when I wrote this, I expected that “implements ArrayAccess” somehow added the ability to use array access on an object. I realize now that this is really platform-dependent – it just hints that it “can”, not enforcing that it will.

In Flash, array access is available on an array, or for dynamic access to object fields. You don’t arbitrarily add it to any object, per se. JavaScript is similar. Haxe does have a method for adding arbitrary array access – it’s called an abstract class, and is a compile-time feature. It also makes sense that Haxe could only truly enforce this markup at compile-time, not runtime.

I’m thinking that perhaps the typed array views should be abstract classes, over the ArrayBufferView class. This would remove the ability to Std.is (object, UInt8Array), unfortunately, but I think it might be best way to get consistency and performance out of the implementation