Grupos » Flash Maniacs » Temas » [T] Delay in AS

Listado 1-5 de 5    1   de  1
Autor Mensaje
Flash Mod

M/22
,
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder a esta publicación Publicado:  nov 25, 2007 2:49 a.m.
Taken from http://www.webwasp.co.uk/

Make a function repeat every interval:

function wait() { // a function called 'wait'
trace("The time is now !!"); // the action you want, in this case a trace.
}
myTimer = setInterval(wait, 1000); // calls the function after 1 second

This will make the function wait one second and then repeat ever second after that.

Make a function wait and then execute once:

function wait() { // a function called 'wait'
trace("The time is now !!"); // the action you want, in this case a trace.
clearInterval(myTimer); //stops the function being called again.
}
myTimer = setInterval(wait, 2000); // calls the function wait after 2 seconds

This will make the function wait 2 seconds and only repeat once.

------------------------------------------------------------------------------------------

Enjoy

~Flash Mod
mike


M/23
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: nov 25, 2007 9:17 p.m.
use setTimeout instead.


make the function as usual but instead of usinger setInterval use setTimeout


setTimeout(function name , delay in milliseconds);

ie:

function hello(){
trace("hello world");
}

setTimeout(hello, 2000);


would trace "hello world" in 2 seconds.
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: nov 25, 2007 9:22 p.m.
nice a bit easier
Listado 1-5 de 5    1   de  1

dspPostReplies v29