I’ve created a class that utilizes setInterval…
I call it in a different class…and I can’t get it to make the setInterval call. I’m thinking there’s a scope problem but I don’t see it.
Class w/ setInterval:
class Foo {
private [COLOR=#000087]var[/COLOR] id:[COLOR=#000087]Number[/COLOR];
public [COLOR=#000087]function[/COLOR] Foo() {
id = -1;
}
public [COLOR=#000087]function[/COLOR] init():Void {
[COLOR=#000087]trace[/COLOR]("[COLOR=blue]init[/COLOR]");
id = [COLOR=#000087]setInterval[/COLOR]([COLOR=#000087]this[/COLOR], "[COLOR=blue]display[/COLOR]", 500);
}
private [COLOR=#000087]function[/COLOR] display():Void {
[COLOR=#000087]trace[/COLOR]("[COLOR=blue]blah here blah[/COLOR]");
[COLOR=#000087]clearInterval[/COLOR](id);
}
}
I use this like:
[COLOR=#000087]var[/COLOR] fooInstance = [COLOR=#000087]new[/COLOR] Foo();
fooInstance.init(); [COLOR=#878787]// I get the "init", but NOT "blah here blah"[/COLOR]
Extra info…if I call:
[COLOR=#000087]setInterval[/COLOR](display, 500);
The function will get called but I need access to the class’s instance variables inside display().
Thanks for any and all help…