Here's what I have so far: http://jsfiddle.net/nxCFn/
var il = new ImageLoader();
function ImageLoader() {
this.n = 2;
this.load = function() {
//obviously, the this = the image and not the original instance of ImageLoader :(
this.n++;
console.log(this.n);
}
this.imgnam = "http://www.google.com/images/errors/logo_sm.gif";
this.img = new Image();
this.img.src = this.imgnam;
this.img.onload = this.load;
}
Because the image is calling .load()
this
from load
points to the image. I want to make this
from load point to the ImageLoader
instance it "belongs" to.