# setInterval for only one time

**URL:** <https://forum.kirupa.com/t/setinterval-for-only-one-time/50378>\
**Category:** flash\
**Created:** [May 2, 2004, 2:19pm UTC](https://forum.kirupa.com/t/setinterval-for-only-one-time/50378 "2004-05-02T14:19:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PixelSense](https://avatars.discourse-cdn.com/v4/letter/p/74df32/32.png) [@PixelSense](https://forum.kirupa.com/u/PixelSense)\
**Post date:** [May 2, 2004, 2:19pm UTC](https://forum.kirupa.com/t/setinterval-for-only-one-time/50378/1 "2004-05-02T14:19:47Z")

</div>

seems that my clearInterval is not working  
i want to make the setInterval only call the function once and stops

here’s my code

```auto
createPortfolio = function (portSource, portLength) {
	// clearInterval(_root.intervalID);
	this.created = false;
	this.onEnterFrame = function () {
		if(this.created == false) {
			for (i = 0; i < portLength; i++) {
				this.attachMovie ("titlemc", "titlemc" + i, 10 + i);
				this["titlemc" + i]._x = 470;
				this["titlemc" + i]._y = (25 * i) + 15;
				this["titlemc" + i].interval = (1000 + (i * 50));
				this["titlemc" + i].count = i;
			
				_root.intervalID = setInterval (delay, this["titlemc" + i].interval, portSource*, this["titlemc" + i]);
				this.created =true;
				
			}
		}else{
			clearInterval(_root.intervalID);
		}
	};
};

delay = function (portSource, myTitlemc) {
	myTitlemc.gotoAndPlay (2);
	myTitlemc.work_name.text = portSource.work_name;
};

```
