//this is a class
function SpriteSheetClass()
{
this.sprite="local";
$.getJSON(url, this.onLoaded);
}
SpriteSheetClass.prototype.onLoaded= function(json)
{
console.log(this.sprite); //returns undefined!
//I am out of SpriteSheetClass scope! how do I store the json???
}
var a=new SpriteSheetClass()
When the getJSON callback is executed, the scope is not in the class. There is no way to bind the returned json with my class instance (a)
Keep in mind I want to keep the calls async, and I need to create many instances of SpriteSheetClass This is not a timing question, it is a scope question.
thanks