I want to read from a json file and use its values to draw triangles. While being in the routine i can print out the value, outside of it, it won't work any more. My code:
faces=new Array(40000);
$.getJSON('file.json', function(data) {
$.each(data.faces, function(i, f) {
faces[i]=new Array(3);
faces[i][1]=data.faces[i].f1;
faces[i][2]=data.faces[i].f2;
faces[i][3]=data.faces[i].f3;
//alert(faces[1][1]); works here
});
});
//alert(faces[1][1]); doesn't work here, console says faces[1][1] is undefined
How can I fix this?