Hey, this is a very simplified version of a Dashboard script I'm writing. I'm new to using objects, so I'm missing something here. I'm trying to figure out why inside download.start() the object variable "this.size" calls the right number, but in download.done(), it's coming up as undefined. Any help?
Code:
var download = {
size : null,
start : function(startSize) {
this.size = startSize;
setTimeout(this.done, 2000);
alert("The Size is: " + this.size);
},
done : function() {
alert("Now, the Size is: " + this.size);
}
}
window.onload = function() {
download.start(10);
}
EDIT - figured it out : setTimeout("download.done()", 2000); b/c when called the "this" is referring the window.
Last edited by funkdaddu; 12-19-2006 at 05:38 PM..
|