Multi dimensional array with get image data
Posted
by
Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2012-03-20T23:16:39Z
Indexed on
2012/03/20
23:29 UTC
Read the original article
Hit count: 190
JavaScript
I'm really confused with an array im making, its gotten a bit confusing to follow but i believe its the only way for me to approach what im trying to do.
My idea here is to store getImageData in an array so i can link each image to an array of data.
This is how i create my array:
var listObj = {
id: uid,
extra: [
ctx2.getImageData(abposx,abposy,imgwidth,imgheight)
]
};
pixeld.push(listObj);
So now im trying to run through the array "pixeld" to find the uid but i don't know how the syntax should be.... this is what i tried:
for (j = (pixeld.length-1); j > -1; --j){
if(pixeld[j].extra.data[3] !==0){ //line 220
matches.push(pixeld[j].id);
}
}
The problem is i get this error:
Uncaught TypeError: Cannot read property '3' of undefined on line 220
I have marked which line is 220 in the for loop.
Any one know what my mistake is ?
© Stack Overflow or respective owner