Good, I have a loop that runs through an array in which there may or may not be loaded images, the issue is that when you crash these images on a canvas and do it in the way you specify in MSDN, I can only load the last image the same number of times I have images in the array. This happens because the image is painted with the onload event that is called at the end of the loading of the page, so the loop has already finished and therefore I only have the information of the last iteration.
for (var i=0; i<array.length; i++){
var data=array[i].campoImagen;
var DOMURL = window.URL || window.webkitURL || window;
var img = new Image();
var svg = new Blob([data], {type: 'image/svg+xml'});
var url = DOMURL.createObjectURL(svg);
img.onload = function() {
ctx.drawImage(img, Window.posx,Window.posy);
DOMURL.revokeObjectURL(url);
}
img.src=url;
}
Also, another problem is that in this way the images are always drawn on top of the texts because they are the last ones to be loaded on the canvas.
Any alternative to load each image in its corresponding iteration?