Easily access an array based on its dimensions

Let's say I have an array that has n dimensions. Now, to access a slot, you usually use:

 array [1][0]

      

What to do if the number of dimensions is unknown at compile time, is there any simple access like:

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

      

This means I can also navigate back and forth easily

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

      

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

In JavaScript, you can:

 slot = "1,0"
 eval("array[" + slot + "]")    // accessing 1,0

      

0


a source to share


1 answer


There is no such object in AS3. Also does not exist eval

(excluded for security reasons mainly IIRC). The latter is also one of the few areas where AS3 differs from the ECMAScript specification.



+1


a source







All Articles