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