View Single Post
Old 11-18-2012, 01:42 AM   PM User | #13
Luke7268
New Coder

 
Join Date: Nov 2012
Posts: 10
Thanks: 6
Thanked 0 Times in 0 Posts
Luke7268 is an unknown quantity at this point
I really appreciate all the hints.

However:

Code:
var loadPictureOnCanvas = function (index, url, sourcepointer, widthpic, heightcanvas) {
	img[index] = new Image();
	img[index].onload = function() {
 		contextsrc.drawImage(img[index], sourcepointer, 0, widthpic, heightcanvas);
	};
	img[index].src = url;
	alert(index);
}

var copyCanvas = function(callback) {
	contextdest.drawImage(canvassrc, 0, 0, widthcanvas, heightcanvas, 0, 0, widthcanvas, heightcanvas);
	alert('thenCopy');
	return callback;
}

var makeSourceCanvas = function(callback) {
	for (i=0; i<numberofpics; i++) {
		loadPictureOnCanvas(i, imgsrc[i], sourcepointer, widthpic[i], heightcanvas);
		sourcepointer=sourcepointer+widthpic[i];
	}
	alert('makeSource');
	return callback;
}

copyCanvas(makeSourceCanvas(callback));
...gives exactly the same issue.

Now I have never worked with asynchronous code before, so I may be entirely missing the purpose of callbacks... Apparently I do, else this would have worked.
Luke7268 is offline   Reply With Quote