Reputation: 290
I have 5 different arrays for a bunch of excercises, like so:
const oef1:Array = ["citroen","schoen","boek"];
const oef2:Array = ["huis","muis","jas"];
const oef3:Array = ["boek","koek","sok"];
const oef4:Array = ["ei","bij","bot"];
const oef5:Array = ["vier","mier","muur"];
Now I want to set the current game. I do this by copying the array, like so:
var curArr:Array;
var curExc:int = 1;
curArr = ("oef" + curExc) as Array;
I can't convince flash to accept the string ("oef"+curExc) as an Array. How do I do this?
I have searched Stack Overflow extensively but I think I simply don't know the correct lingo for what I'm looking for. It's the only possible reason I can think of why I can't find the answer here because I'm sure someone must have already tried this. Apologies if this is the case, please point me to the right question.
Upvotes: 0
Views: 114
Reputation: 2009
You could make a two-dimensional array, like so:
wrapper => [
0 => oef1,
1 => oef2,
2 => oef3,
3 => oef4,
4 => oef5,
]
And just retrieve wrapper[curExc]
.
Have a great day.
Upvotes: 0
Reputation: 10325
const oef1:Array = ["citroen","schoen","boek"];
const oef2:Array = ["huis","muis","jas"];
const oef3:Array = ["boek","koek","sok"];
const oef4:Array = ["ei","bij","bot"];
const oef5:Array = ["vier","mier","muur"];
const oefArrays:Array = [oef1,oef2,oef3,oef4,oef5];
var curArr:Array;
var curExc:int = 0;
curArr = oefArrays[curExc];
Upvotes: 2