setInterval()? play in every 5secs

HellO! :slight_smile:
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 :frowning:
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:

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

It is the first script on that page.

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…

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

pom :cowboy:

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

Best get ta readin’ then :stuck_out_tongue:

I read it, it is very informative :slight_smile:

Thanks Ilyas.

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

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

Everything is in that link!! :trout:

Basically, it updates after an ā€œasynchronousā€ event. Sort of.

I figured since it was brought back Id throw this up too…
h88 had some suggestions which Ill add to it over the weekend :wink:
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)

*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. : )