fleeklee
07-27-2003, 11:48 PM
Hi,
I have the following code
MyClass.prototype.myVar = "some value";
MyClass.prototype.buildScreen = function() {
[create button]
button.onPress = ???
}
MyClass.prototype.foo = function() {
trace(this.myVar);
}
My problem is that I want the onPress event handler to cause a call to foo();
I've tried
button.onPress = function() {
this.foo();
}
but "this" in this context is the button.
I've also tried things similar to
button.onPress = this.foo;
but the "this" reference within foo() becomes the button as well, making "myVar" unavailable.
Any ideas besides storing the MyClass instance in a global?
Thanks,
Ken
I have the following code
MyClass.prototype.myVar = "some value";
MyClass.prototype.buildScreen = function() {
[create button]
button.onPress = ???
}
MyClass.prototype.foo = function() {
trace(this.myVar);
}
My problem is that I want the onPress event handler to cause a call to foo();
I've tried
button.onPress = function() {
this.foo();
}
but "this" in this context is the button.
I've also tried things similar to
button.onPress = this.foo;
but the "this" reference within foo() becomes the button as well, making "myVar" unavailable.
Any ideas besides storing the MyClass instance in a global?
Thanks,
Ken