# setInterval()? play in every 5secs

**URL:** <https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535>\
**Category:** Uncategorized\
**Created:** [November 2, 2002, 4:34pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535 "2002-11-02T16:34:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [November 2, 2002, 4:34pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/1 "2002-11-02T16:34:29Z")

</div>

HellO! 🙂  
Question:  
How can I make a movieclip play in every 5 seconds.

exmpl: When 5 seconds are full the mc starts playing and then the timer starts counting from 0 and then somewhere there is a stop action and when 5 seconds are elapsed again it plays on…

I tried

onClipEvent (enterFrame) {  
playmc = function () {  
\_root.mc.play();  
};  
setInterval( playmc, 5000 );  
}  
but it didn’t work ☹  
It holds for five seconds… then starts playing(no problems for now) but it never stops it plays on and on and on and on…  
Like it counts to five and lets go the play() action for onClipEvent(enterFrame) or something…  
What the \*\*\*\* am I doing wrong???:q:

---

<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:** [November 2, 2002, 5:29pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/2 "2002-11-02T17:29:39Z")

</div>

So you want to pause your movie for x number of seconds?

If so, try this…

[http://www.actionscript.org/actionscripts\_library/main/search.cgi?query=Pause+-+Flash+MX](http://www.actionscript.org/actionscripts_library/main/search.cgi?query=Pause+-+Flash+MX)

It is the first script on that page.

---

<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:** [November 2, 2002, 7:02pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/3 "2002-11-02T19:02:11Z")

</div>

well …yeah…  
Acually want it to trigger a play() action in every x seconds but I think it can be done that way too…  
BUT! I don’t understand anything about that script…  
wtf is clearinterval???  
and what is obj, id, pzeit …  
I don’t visit that site cuz there are no explanations of what each action does…  
I searched the flash help for the clearinterval but I didn’t understand the explanations either… :\*(  
This is so annoying! This little thingy-so big problem…

---

<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:** [November 2, 2002, 7:11pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/4 "2002-11-02T19:11:00Z")

</div>

When you set an interval, your function will execute again and again until you clear the interval.

Check this link, you’ll find everything you need to know:  
[http://www.friendsofed.com/books/flash\_mx\_titles/fresh\_flash/fresh\_samplechapter.pdf](http://www.friendsofed.com/books/flash_mx_titles/fresh_flash/fresh_samplechapter.pdf)

pom :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:** [November 2, 2002, 7:33pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/5 "2002-11-02T19:33:32Z")

</div>

humh… this is some hard-time reading for this little thingy…😏  
thx 😏

---

<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:** [November 2, 2002, 9:57pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/6 "2002-11-02T21:57:26Z")

</div>

Best get ta readin’ then 😛

I read it, it is very informative 🙂

Thanks Ilyas.

---

<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:** [February 14, 2003, 4:42am UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/7 "2003-02-14T04:42:53Z")

</div>

Hi syko,

You can trigger the play command at x milliseconds for a specific movie, Here is a working example:

MovieClip.prototype.play2 = function(){  
this.play();  
updateAfterEvent();  
}  
myInterval = setInterval(YourMovie, “play2”, MiliSeconds)

And if you want to stop the interval, just clear it, or run the function stop2.

\_global.stop2 = function(){ clearInterval(myInterval);}  
//stop2(); will clear the interval

I just found this post, and i thought i should answer…lol

---

<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:** [February 14, 2003, 1:29pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/8 "2003-02-14T13:29:06Z")

</div>

lol seems like a nice piece code! ! question though!  
What does updateafterevent() do?  
=)

---

<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:** [February 14, 2003, 1:35pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/9 "2003-02-14T13:35:24Z")

</div>

Everything is in that link!! :trout:

Basically, it updates after an “asynchronous” event. Sort of.

---

<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:** [February 14, 2003, 2:23pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/10 "2003-02-14T14:23:25Z")

</div>

I figured since it was brought back Id throw this up too…  
h88 had some suggestions which Ill add to it over the weekend 😉  
[http://www.umbc.edu/interactive/flash/tutorials/setInterval.php](http://www.umbc.edu/interactive/flash/tutorials/setInterval.php)

not as long but hopefully helpful

… btw note that a setInterval shouldnt be called in an enterFrame event because thats redeclaring the interval everyframe which you dont want (I think Ill add that in there too)

---

<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:** [February 14, 2003, 3:03pm UTC](https://forum.kirupa.com/t/setinterval-play-in-every-5secs/7535/11 "2003-02-14T15:03:08Z")

</div>

> \*Originally posted by senocular \*  
> \*\*… btw note that a setInterval shouldnt be called in an enterFrame event because thats redeclaring the interval everyframe which you dont want (I think Ill add that in there too) \*\*

You might also consider setInterval a replacement of enterFrame tho, it looks similar, but setInterval is Time dependent, and enterFrame is frame dependent.

Believe me ilyas i haven’t read the whole chapter, it was really so much to just explain a small command.

Really nice article senocular. : )
