Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : Why this code isn't working?


mballom3
6/25/2005 9:14:01 PM
Hi all,

Would be nice if anyone can explain me why i can't get this setInterval code
working:

stop();
function myFunction {play();
}
ID = setInterval (myFunction, 3*1000)
clearInterval(ID);

This goes on frame 50 on main timeline. I want this frame to pause 3 seconde,
then keep playing from nextframe.
Well nothing of this happens. The timeline simply plays throught as tho
nothing was there.

Thanks for answers




myIP
6/25/2005 10:04:10 PM
You forgot to add the parentheses when you declared ?myFunction?. Also the
setInterval( ) was initiated and immediately cleared by your clearInterval( ).
You what to add the clearInterval( ) inside your function.

function myFunction()
{
trace("3 secs have passed");
play();
clearInterval(ID);
}
ID = setInterval (myFunction, 3000)
stop();
mballom3
6/25/2005 10:25:32 PM
mballom3
6/26/2005 12:00:00 AM
I corrected the code and the pausing of the frame 50 works fine. I had a stop
action on frame 140 (which is the last of my movie), but when i play it back,
the movie loops instead of stoping there (test movie , IE, nestcape). What is
the problem now? Might it be because of that setInterval action on frame 50??
if not why can't flash read that stop command?

Laiverd.COM
6/26/2005 12:01:30 AM
Put the clearInterval(ID) inside the function, otherwise it gets cleared immediately. And please in the future refrain from
crossposting. As at times one may be in doubt where to post, this clearly is an as question so this is the appropriat eplave.

John

--
---------------------------------------------------------------------------------------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
---------------------------------------------------------------------------------------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
---------------------------------------------------------------------------------------

AddThis Social Bookmark Button