# Cannot clearInterval in class

**URL:** https://forum.kirupa.com/t/cannot-clearinterval-in-class/199454
**Category:** flash
**Created:** [September 2, 2006, 5:37pm UTC](https://forum.kirupa.com/t/cannot-clearinterval-in-class/199454 "2006-09-02T17:37:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![krystle](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krystle/32/1239_2.png) [@krystle](https://forum.kirupa.com/u/krystle)
#### Post date: [September 2, 2006, 5:37pm UTC](https://forum.kirupa.com/t/cannot-clearinterval-in-class/199454/1 "2006-09-02T17:37:29Z")

</div>

Hi:

I have just started working with classes and am having trouble using setInterval/clearInterval in the class. I am sure my scoping is incorrect but I am not sure how to fix it. My problem (simplified) is below:

```auto
class myClass extends MovieClip {
var loopImage:Number

function myFunc1(){
loopImage = setInterval(cycleImages, 4500);

}

function myFunc2(){
clearInterval(loopImage);
}

function cycleImages(){
//irrelevent whats in here
}

}

```

Bascially, how do I set up my interval so that when “myFunc2” is called, loopImage is not undefined and it is able to clear the interval.

Thanks in advance.
