Transition.start = function(){
for(var j = 0; j < 6; j++)
{
console.log("FOR LOOP");
(function(){
console.log("INNER Function");
var image = new Image();
image.src = path + Config.imgName[j] + ".jpg";
image.onload = function () {
console.log("GONE");
clearImages[source].push(image);
console.log(image);
};
})();
}
}
In this on console "FOR LOOP" and "INNER Function" is printed 6 times, but "GONE" is printed 12 times. I am not able to figure out the reason for this. I want to run the body of onload also 6 times.
and Transition.start is called from onDocumentKeyDown listener like this
function onDocumentKeyDown( event )
{
if (keyPressed == 38) //up arrow
Transition.start();
}
console.trace()?