Question

Lets say I have an array which has n dimensions. Now in order to access a slot you typically use:

 array [1][0]

What if the number of dimensions are not known at compile-time, is there an easy access like:

 slot = "1,0"
 array [slot]   // accessing 1,0

Which means I can also easily navigate back and forth

 slot += ",2"
 array [slot]   // accessing 1,0,2

Any such way to access any slot in a multidim array in one line of code, in ActionScript? I'm not looking for alternative code, that does it indirectly, (recursive functions or loops).

In JavaScript you could:

 slot = "1,0"
 eval("array[" + slot + "]")    // accessing 1,0
Was it helpful?

Solution

There is no such facility in AS3. Neither is eval (taken out due to security reasons mostly, IIRC). The latter also being one of those few areas where AS3 differs from the ECMAScript specification.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top