I have a strange error. My application compiles but gets a runtime error when trying to read the length of an OpenFL Vector. See comment below.
private function set_pointData(data:Vector<Vector3D>):Vector<Vector3D>
{
if (data.length < _pointsPerSegment) … //throws an error saying "Uncaught TypeError TypeError: data.get_length is not a function
In debug mode, when I break on that line I can see that the data consists of 46 entries and does have a length property. I’m compiling to JavaScript. I tried setting -dce to “no”. What could be the problem?
There seems to be something about starting with an Array and casting it to Vector of the same length. Compiling to Hashlink fails with Uncaught exception: Can't cast hl.types.ArrayObj to openfl._Vector.ObjectVector but compiling to JavaScript works fine, and the casting works.
If I start with a Vector and populate that before passing to the function, things work fine. I have it working now.
What I did was create an Array and then called: set_pointData(cast(myArray));
At runtime I set a breakpoint within the set_pointData function and inspected the “data” variable. It was populated as I expected in the debugger and did have a length. No error happened until later on in the function it attempted to read the length.