Is there a way to make an array composed of “tags”, so I can refer to them by their “name”?
So usually when I want to refer to a position in my array I would do something like:
MyArray:Array = new Array( ["Marco", 26, "Portugal" ] );
trace(MyArray[2]);
Output: "Portugal"
I want to use an array where the positions have diferent names. So I wanted to be something like:
MyArray:Array = new Array( ["Marco", 26, "Portugal" ] );
trace(MyArray[Country]);
Output: "Portugal"
I’m pretty sure “tag” or “name” of the array isnt the propper term to use, but I don’t know the correct one, so excuse me on that. Its also probably a easy question, but something that I never needed to use untill now. I’m building a “Area” array with positions, heigths and widths of several movieclips on stage, so I could use some simplification of the array to avoid always using numbers.
Thank you.
You can just use the
Objectclass, it is the simplest way to use associative arrays in as3:I recommend you to check this article on Adobe’s website for further info: ActionScript 3 fundamentals: Associative arrays, maps, and dictionaries