# setInterval

**URL:** <https://forum.kirupa.com/t/setinterval/6923>\
**Category:** flash\
**Created:** [October 20, 2002, 2:22am UTC](https://forum.kirupa.com/t/setinterval/6923 "2002-10-20T02:22:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcogswell11](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@bcogswell11](https://forum.kirupa.com/u/bcogswell11)\
**Post date:** [October 20, 2002, 2:22am UTC](https://forum.kirupa.com/t/setinterval/6923/1 "2002-10-20T02:22:43Z")

</div>

Hey guys, I am posting this because I am having a ton of trouble with a script of mine. First of all, here is the code:

```auto

moveMe = function () {
	this.targx = Math.round(Math.random() * 550);
	//trace(this.targx);
	this.dx = (this.targx - this._x)*.01;
	this._x += this.dx;
}
moveline.onEnterFrame = moveMe;

```

What I want to have happen is to use setInterval and have it wait for, say 2 seconds. However, when I use this, it doesn’t work at all.

```auto

setInterval = (moveMe, 2000);

```

I have tried many ways of writing this and putting it in different places, but still nothing. Could it be because I am using the onEnterFrame to execute the function?

I have looked around the forums for a long time to try to solve my problem, but I can’t find how to get setInterval to work with my script.

Thanks guys!  
-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 2:32am UTC](https://forum.kirupa.com/t/setinterval/6923/2 "2002-10-20T02:32:27Z")

</div>

Are you trying to pause your timeline for x number of seconds? Or just a specific object?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 2:42am UTC](https://forum.kirupa.com/t/setinterval/6923/3 "2002-10-20T02:42:21Z")

</div>

Just the specific script. Right now, the ocject will randomly move, however it doesn’t reach its destination. It just wobbles back and forth because there isn’t any time to move before it picks a new random number and destination. I want to give it about two seconds to travel along before we repick the destination.

-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:10am UTC](https://forum.kirupa.com/t/setinterval/6923/4 "2002-10-20T03:10:02Z")

</div>

This doesn’t fix the problem, but I can see one error…

Set Interval looks like this…

setInterval(moveMe, 2000)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:21am UTC](https://forum.kirupa.com/t/setinterval/6923/5 "2002-10-20T03:21:30Z")

</div>

Yeah that’s what I had, I just wrote it wrong in the forum.

-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:28am UTC](https://forum.kirupa.com/t/setinterval/6923/6 "2002-10-20T03:28:58Z")

</div>

This is what I have so far

```auto
moveMe = function () {
	this.targx = Math.round(Math.random()*550);
	// trace(this.targx);
	this.dx = (this.targx-this._x)*.01;
	this._x += this.dx;
};
setInterval(function () {
	trace("2 seconds passed");
	moveline.onEnterFrame = moveMe;
}, 2000);

```

This first delays your clip 2 seconds, but then after that it does what it does in the first place. Getting there though.

Not sure how long I can work on this, but I will be for a little while.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:49am UTC](https://forum.kirupa.com/t/setinterval/6923/7 "2002-10-20T03:49:29Z")

</div>

Your footer crashes my Netscape 7… :evil:

Fine on IE 6… =)

Are you using something different than just an swf? Not that it matters much, I’m just curious… :-\

Yours is the only one which crashes N7… :q:

Rev:elderly:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:53am UTC](https://forum.kirupa.com/t/setinterval/6923/8 "2002-10-20T03:53:35Z")

</div>

Is it his?..or mine???

Mine uses .png images which can be known to take up system resources if you use to many in motion.

I haven’t had any complaints about it though.

:::opening netscape 7:::

I will let you know if anything happens on my side rev

EDIT/UPDATE: Works perfectly fine in my NS7 rev.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 3:56am UTC](https://forum.kirupa.com/t/setinterval/6923/9 "2002-10-20T03:56:05Z")

</div>

Hmmm Reverend, sorry about that. It is just a .swf though. When I have more itme I will change it.

-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 4:04am UTC](https://forum.kirupa.com/t/setinterval/6923/10 "2002-10-20T04:04:38Z")

</div>

No, no need to change… I use IE a lot as well… =)

I was just curious why yours didn’t work as well as anybody else’s (only seems to happen when you post, for some odd reason)… :q:

I’m still trying to decide whether I like N7… and I’m leaning against, just becuase of quirks like this… :-\

Could be my lame-ass 'puter (still using a 450Mhz Frankenstein looking piece o’crap)… especially since Lostinbeta’s N7 works…

Maybe my N7 doesn’t like you… 😛 jk (prob jealous)

Thanks guys, for responding, =)

Oh, and GO GIANTS!!!

Rev:elderly:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 4:11am UTC](https://forum.kirupa.com/t/setinterval/6923/11 "2002-10-20T04:11:03Z")

</div>

Yeah I just finished watching the game. Dominant force! Hey, it seems this thread has gotten off track though a little, can anyone help me with my setInterval problem?

-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 4:12am UTC](https://forum.kirupa.com/t/setinterval/6923/12 "2002-10-20T04:12:44Z")

</div>

sorry, back to your regularly scheduled programming… :cool:

:::goes and sits in corner…again:::

Rev:elderly:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 7:27am UTC](https://forum.kirupa.com/t/setinterval/6923/13 "2002-10-20T07:27:11Z")

</div>

Well, doesn’t Lost’s code work?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 7:32am UTC](https://forum.kirupa.com/t/setinterval/6923/14 "2002-10-20T07:32:13Z")

</div>

OMG guys I’m sorry. \*\*\*\*it I’m way too tired. I have been periodically checking back to see if someone had replied when Lost had awhile back and I had somehow looked over his post! Then I asked if we could get the thread back on track…wow. I have got to get some sleep. See you all in the morning.

-brad-:cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 7:36am UTC](https://forum.kirupa.com/t/setinterval/6923/15 "2002-10-20T07:36:26Z")

</div>

😛 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 7:46am UTC](https://forum.kirupa.com/t/setinterval/6923/16 "2002-10-20T07:46:05Z")

</div>

OK last post for the night, I swear!

You are right Lost, the clip is delayed for 2 seconds, and then it does the random motion that it usually does. I don’t really care about the delay in the beginning, if possible that shouldn’t do that. It should pick the destination, wait 2 seconds, and then repick another destination. (over and over again in this loop) I will work more on it tomorrow. Let me know if you find anything.

-brad-:cowboy:
