# How to use setInterval to delay event, not just each step of event

**URL:** <https://forum.kirupa.com/t/how-to-use-setinterval-to-delay-event-not-just-each-step-of-event/146824>\
**Category:** Uncategorized\
**Created:** [May 4, 2005, 2:26pm UTC](https://forum.kirupa.com/t/how-to-use-setinterval-to-delay-event-not-just-each-step-of-event/146824 "2005-05-04T14:26:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jillymo](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jillymo](https://forum.kirupa.com/u/jillymo)\
**Post date:** [May 4, 2005, 2:26pm UTC](https://forum.kirupa.com/t/how-to-use-setinterval-to-delay-event-not-just-each-step-of-event/146824/1 "2005-05-04T14:26:21Z")

</div>

I had some help in setting up this bit of code to fade out a loaded movie:

```auto
function faderFunc() {
_root.holder24._alpha -= 5;
if (_root.holder24._alpha < 0) {
_root.holder24._alpha = 0;
clearInterval(fadeRMS);
}
};
fadeRMS = setInterval(faderFunc, 400);

```

Trouble is, I am looking to fade the clip slowly to zero once it has been a certain number of seconds, rather than just having the clip fade at a rate of -5 every so many seconds as it is set here.

In comparing this to other code that I have been using setInterval in, I am wondering if the problem is that this setInterval is not control an onEnterFrame event, but rather just control the rate of the alpha fade. I don’t see how I could use an on enterFrame with this because the swf has already been loaded into a movie in this same Frame…maybe I am wrong about both of these thoughts, maybe just one.

I would really appreciate some insight on this I have been working with different attempts for a while and cannot get the results I want.

(Here is an example of some other code I am using that does delay the onEnterFrame event, I think, so that the code is not being fully executed until 57 seconds pass…)

```auto
function moveRMS() {
	clearInterval(moveRMSInterval);
	unloadMovie(_root.holder22);
	xstep=(30-holder24._x)/5
	ystep =(500-holder24._y)/5
	_root.holder24.onEnterFrame = function() {
		this._y -= (577-this._y)/ystep;
		this._x -= (865-this._x)/xstep;
		if (Math.abs(577-this._y)<1 && Math.abs(865-this._x)<1) {
			this._y = 577;
			this._x = 865;
			delete this.onEnterFrame;
		}
	};
}
moveRMSinterval = setInterval(moveRMS, 57000);

```
