# Want to delay....not keep spazzing out

**URL:** <https://forum.kirupa.com/t/want-to-delay-not-keep-spazzing-out/117757>\
**Category:** Uncategorized\
**Created:** [July 30, 2004, 1:19am UTC](https://forum.kirupa.com/t/want-to-delay-not-keep-spazzing-out/117757 "2004-07-30T01:19:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![H4T](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/h4t/32/329_2.png) [@H4T](https://forum.kirupa.com/u/H4T)\
**Post date:** [July 30, 2004, 1:19am UTC](https://forum.kirupa.com/t/want-to-delay-not-keep-spazzing-out/117757/1 "2004-07-30T01:19:35Z")

</div>

I’ve got a bubble, and I want this bubble to wobble to a random spot, sit there for a couple seconds, then wobble to another spot. By wobble I mean get to that spot with elasticity.

Below is the code I’m using, and the bubble keeps spazzing out. I want him to pause, but the setInterval doesn’t seem to be doing anything…

```auto
onClipEvent(enterFrame) {
 	 jump = function() {
 		var newX = random(100)*5;
 		var newY = random(100)*5;
 		
 		this._x = (newX - this._x)/2;
 		this._y = (newY - this._y)/2;
 		
 		clearInterval(sit);
 	}
 
 	sit = setInterval(jump, 1000);
 }

```

---

<div class="post-metadata">

**Author:** ![bobdoe](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bobdoe](https://forum.kirupa.com/u/bobdoe)\
**Post date:** [July 30, 2004, 5:10am UTC](https://forum.kirupa.com/t/want-to-delay-not-keep-spazzing-out/117757/2 "2004-07-30T05:10:28Z")

</div>

I think the reason why its spazzing out is because you are constantly calling the jump function. On every frame of your swf, flash calls the jump function with 1 second intervals. It does this on frame 1, frame 2, frame 3, frame 4…and so on. So it keeps calling itself, and then it keeps deleting itself by clearInterval. Therefore, nothing happens. I dont think setInterval should be nested inside enterFrame events, things just get messy this way.
