# \[AS2\] problem with setInterval

**URL:** <https://forum.kirupa.com/t/as2-problem-with-setinterval/176733>\
**Category:** flash\
**Created:** [January 26, 2006, 1:55pm UTC](https://forum.kirupa.com/t/as2-problem-with-setinterval/176733 "2006-01-26T13:55:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![panhead490](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@panhead490](https://forum.kirupa.com/u/panhead490)\
**Post date:** [January 26, 2006, 1:55pm UTC](https://forum.kirupa.com/t/as2-problem-with-setinterval/176733/1 "2006-01-26T13:55:37Z")

</div>

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:

```auto

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:

```auto

[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:

```auto
[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…
