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 ?
So your structure look like the following:
Now the question is: What is
ctx.2.getImageData()returning? You need to clarify that.Until
pixeld[j].extraeverything is fine, but there is nodata-property. IfgetImageData()really returns an array, you should be able to access like this: