array?
- Started
- Last post
- 7 Responses
- pushme
Ok. So i'm trying to modify a tsunami as 2.0 example. The code has the below in it. Is this some sort of array?:
items: [
{ id: 'selection', label: 'Selection', xPos: '0', yPos: '-106'},
{ id: 'honeymoon', label: 'Honeymoon', xPos: '143', yPos: '-102' },]
- joyride0
yes, it is a multi dimensional associative array i believe
- blaw0
good information here:
http://livedocs.macromedia.com/l…too bad it's on that shitty 'livedocs' server.
- st33d0
I don't think it's an ascociative array. It's actually an array of objects.
item[0] = { id: 'selection', label: 'Selection', xPos: '0', yPos: '-106'};
item[1] = { id: 'honeymoon', label: 'Honeymoon', xPos: '143', yPos: '-102' };
item[0].id = 'selection';
item's elements should identify as Object.
- enjine0
items is the array
(it's declared with the two straight brackets which are the outtermost characters)the numbered elements 0, 1, ... are the indexes of the array
the indexes, in this example are referring to what is called unnamed Objects. The curly braces declare that it is an object that is being instantiated, sans object name, and the items in the curly braces-- id:'selection'-- are the propery/value pairs.
declaring an unnamed Object like that is the same thing as saying
var obj = new Object();
obj.id = "selection";
obj.label = "Selection";
obj.xPos = "0"etc...
but you can't refer to an unnamed Object after it is created unless it is stored somewhere, hence the need for the 'items' array.
- pushme0
enjine this was very helpful. thank you.
- enjine0
no prob. good luck
- Mimio0
Looks like an array to initialize a class. Those properties are probably already declared somewhere else.