View Single Post
Old 11-17-2012, 08:34 PM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
I think this is maybe a closure issue. the onload events don't fire until all the loops have finished, in which case i is 9 (or 10) for all of the images.

Code:
for (i=0; i<numberofpics; i++) {
	img[i] = new Image();
	img[i].onload = function() {
                var keepi = i;
 		ctxsrc.drawImage(img[keepi], sourcepointer, 0, widthpic[keepi], heightcanvas);
		sourcepointer=sourcepointer+widthpic[keepi];
	};
	img[i].src = imgsrc[i];
}
Otherwise, I would try setting the .src before assigning the onload events.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
Luke7268 (11-18-2012)