I am trying to access an object's member variables from inside a method that is passed as a callback which is fired during a filereader event.
I have whipped together the code below just to try and convey my point. It appears that 'this' becomes the filereader instead of the object at the point of call. Is there a way to have the finishLoading be able to access the objects variables?
I would like to make sure that the callbacks are tailored to the object, otherwise I would have just defined them as static functions outside the class.
function myClass(newName)
{
this.name = newName;
this.m_fileReader = new FileReader();
this.finishedLoading =
function(param1)
{
alert(this.name);
};
this.m_fileReader.addEventListener('loadend',
this.callback_finishedLoading,
false);
}
var instance = new myClass('timmy');
var instance2 = new myClass('joe');