array of objects
- Started
- Last post
- 23 Responses
- ozhanlion
what is wrong here?
myArr = [];
for (var i = 0; i
- alexkxs0
the syntax and structure
- ozhanlion0
shit
myArr = [];
for (var i = 0; i
- j_red0
i think the problem is that pvn doesn't support some characters.
hahahaha.
- ozhanlion0
myArr = [];
for (var i = 0; i is smaller than 5; i++) {
myArr[i] = i;
myArr[i].y = 100+i;
trace(myArr[i].y);
}
- ozhanlion0
this trace gives me undefined. why is that ?
- alexkxs0
i tho i equals 0
- ozhanlion0
can you elaborate?
- unfittoprint0
myArr = [];
function obj(n:Number, y:Number) {
this.n = n;
this.y = y;
}for (i=0; i
- alexkxs0
u define i =0, then less than 5..whats that all about?
- unfittoprint0
merda______
myArr = [];
function obj(n:Number, y:Number) {
this.n = n;
this.y = y;
}for (i=0; i < 5; i++) {
myArr[i] = new obj(i, 100+i)
trace(myArr[i].n+" | "+myArr[i].y);
}
- alexkxs0
oh yah its the limit nm
- unfittoprint0
the reason is that you can only add methods/vars if your variable's an object.
since you're populating it first with a Number you can't add y as a variable to it.
- ozhanlion0
myArr = [];
function obj(n:Number, y:Number) {
this.n = n;
this.y = y;
}for (i=0; i
unfittoprint
(Jan 13 05, 05:06)AHAHAHAHAHAAHAHAHAHAHAHAHA
I haven'tlaughed so hard since high school
- ozhanlion0
Thanks unfit, that explains it all.
- ozhanlion0
ok can I populate my Arr element as object so that I can add a variable to it ?
- ozhanlion0
just like in your example of course..
*slaps himself.
- bk_shankz0
I think you should use pull and pop which are special array methods. push adds an element.
myArr.push(mymc).
- ozhanlion0
yummy!
thanks d00d.