I have this piece of code (sCtx is the canvas context and the button is in a tight loop):
function Button(src, onClick)
{
this.loaded = false;
this.image = new Image();
this.image.src = src;
this.onClick = onClick;
}
Button.prototype.draw = function()
{
if(!this.image.complete)
return;
var theImg = this.image;
console.log(theImg);
sCtx.drawImage(theImg);
}
When I run the code (in Chrome), I get this output:

Dug TypeError: Type Error
Can someone tell me what I'm doing wrong? I looked at a lot of examples, and it looks like this should work.
source
share