# setInterval and AS2 classes

**URL:** <https://forum.kirupa.com/t/setinterval-and-as2-classes/81651>\
**Category:** flash\
**Created:** [March 3, 2005, 11:00pm UTC](https://forum.kirupa.com/t/setinterval-and-as2-classes/81651 "2005-03-03T23:00:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojoNYC](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mojoNYC](https://forum.kirupa.com/u/mojoNYC)\
**Post date:** [March 3, 2005, 11:00pm UTC](https://forum.kirupa.com/t/setinterval-and-as2-classes/81651/1 "2005-03-03T23:00:27Z")

</div>

i’m having an issue fitting setInterval() methods into an AS2 class–basically, since setInterval works by calling a function at a set interval, and it returns an object reference, like this:

```auto

public function loadSplash():Void {
	var id=setInterval(loadSplashMC,1000);
		var sM:Object=new Object();
		Mouse.addListener(sM);
		sM.onMouseMove=function(){  
			Mouse.removeListener(this); //delete after first mouse event
			}}	
			
public function loadSplashMC():Void { 
	clearInterval(id);
	}	

```

the problem is that i can’t set a class variable to id–i tried defining it as a generic object, like this:

public var id:Object;

but it didn’t work…

i’m not used to working with setInterval, so maybe i’m just not using it right–perhaps i should put it all into one function?

i think there has to be a better way, and i’d appreciate hearing anything about setInterval() and my problem–thanks!
