views:

91

answers:

1

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
+1  A: 

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.

dirkgently
How about AS2? Would ActionScript 2 support any such feature?
Jenko
Haven't used AS2. There is an eval() -- you can give it a try.
dirkgently
I hope I don't have to mark this as the accepted answer, it would be such a pity!
Jenko
Honestly, I don't get your point. Are you saying that the only acceptable answer is what you would like it to be?
dirkgently
i.e. I'd wouldn't like to conclusively accept defeat, in that the platform supports no such feature. That would be a pity.
Jenko