# Arrays? Still not getting it, final topic about it.

16 posts

 Since i am still not getting what arrays is, i will try to formulate my question well. So you can understand why i am a noob, well not noob right now on flash (since i´ve been working on little side project´s:) ). Anyway, my question is that. Yes i know i already asked, but what is arrays? Really, i know it is an Element you put the but what is an element too? Exampel, I often seen tutorials like this. myArray=[“a”, “b”, “c”, “d”]; (thanks to kongregate people for helping me find tonypas tutorials). Anyway what is that a, b, c, d? is that symbols i´ve created? Like or is it a instance name of the symbol that places the symbol (object) on stage? I really don´t get it i´ve been searching a lot but no one actually answers what arrays are and why are they useful. So i´ve been sitting here thinking a lot. Since i must make a game for my Computer (web classes flash etc;) teacher to get an A in Flash i would want to make a game. But i´ve think the game would be unnecessary to do if i don´t learn anything. Hope you understands my questions. Summary, What is arrays? What is the A, B , C, D? What is element? sorry for not being able to understand but it feels like i really want to know how that works. An array is a collection of variables. You could create a variable a, and b, and c, and d. Then you address them as such. Which would make it annoying to search each one in a loop. An array is just multiply variables (which are the elements of the array), stored under the same name for easy access. Each variable is in a position starting from 0 (A is 0, B is 1, and D is 3, the size is 4 since 0 is a number). The Shootorials use an array to store the symbols of enemies, but it is just a list of variables. Arrays is like a collection of random things put together for easy reference. The A, B, C, D are the elements of the array. Basically, each element is each “thing” that you’re putting inside the array. So, the array can contain basically anything. Number, strings, objects, symbols you’ve created, etc. so you can say (assuming player is the instance name of something) ` var myArray = ["a", 1, -55, player]; ` This would be a collection of the string “a”, the numbers 1 and -55, and the instance player. To access stuff, you would do myArray[index]. Index is an integer that starts at 0, and goes up to myArray.length-1. So, the string “a” in the array above would have an index of 0, and the player would have an index of 3. Small test: what is ` myArray[1] + myArray[2] ` The reason many people use arrays is not only because it’s neater to keep everything together, but because there are ways to traverse through every element of the array. Lets say there’s another array: ` var anotherArray = [player1, player2, player3, player4]; ` In your game, there’s an enter frame event where you want to call the move() function of each player. But, you find it annoying to type player1.move(); player2.move()… etc. If you have them kept in an array, you can instead do: ` for (var i=0; i