00:00
00:00

AS: Timeouts 2005-09-09 11:17:55


AS: Main

This tutorial works in flash 8+

Timeouts are very similar to Intervals and exist in corrosponding languages like JavaScript for just as long.

The main difference is that timeouts only trigger Once after the given ammount of time passes and never again. This is very importent and much needed, and although it can be surpassed with an interval clearning itself, it's much niftier.

First of all let's look at the setTimeout function :

id= setTimeout(functioname:Function, miliseconds:Number, params:Object);

the id is for clearTimeout which I don't know if exists since it's pointless.
The function is the function name to execute when the timeout ends
the miliseconds are the ammount of time the timeout will execute in, for example 2000 miliseconds are 2 seconds.
the params are additional params passed to the function
overall the function is very similar to setInterval and setTimeout in javascript

lets look at this example:

setTimeout(function () {
trace("timed out");
}, 2000);

this would trace "timed out" after 2 seconds, this can be used for all actions needed, and it's good when you want to avoid the frames per second limit.

Ask any questions here
I couldn't find any documentation found , if you did, please share

Response to AS: Timeouts 2005-09-09 11:28:12


So does timeout work independantly from the FPS? and would it use less CPU than say :

a++;
if (a >= 2000){
do stuff
}

and did you mean that setintervals are better? i couldnt quite understand - sorry for my stupidness.

Response to AS: Timeouts 2005-09-09 11:30:01


At 9/9/05 11:17 AM, Inglor wrote:
This tutorial works in flash 8+

That could be useful.. could definitly save time.

I can see a lot of new tutorials coming about Flash 8, the filters and such.. =P


Sup, bitches :)

BBS Signature

Response to AS: Timeouts 2005-09-09 11:30:51


At 9/9/05 11:28 AM, LEMITUDE wrote: a++;
if (a >= 2000){
do stuff
}

LOL that wouldnt time acturately at all sorry, timeout will likely use more cpu but it will actually time properly, what you just suggested is absurd.

Thanks for that Inglor.

Response to AS: Timeouts 2005-09-09 11:34:50


didnt even know they existed lol, thx for that


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to AS: Timeouts 2005-09-09 11:39:19


At 9/9/05 11:34 AM, dELta_Luca wrote: didnt even know they existed lol, thx for that

It doesn't yet =P

Inglor, how about getting a head start and making a flash 8 filters AS? I only know how to use blur and shadow XD Oh and cache as a bitmap, but that is unrelated.


Sup, bitches :)

BBS Signature

Response to AS: Timeouts 2005-09-09 11:41:26


make a AS blurs, you have some version of the 8 filters, don't you? SEPTY and even flash mx 2004 know how to publish flash 8 files, pretty silly...

Response to AS: Timeouts 2005-09-09 11:48:10


At 9/9/05 11:30 AM, T-H wrote: LOL that wouldnt time acturately at all sorry, timeout will likely use more cpu but it will actually time properly, what you just suggested is absurd.

Yea, but that was my point... sometimes you just want a simple interval in there, without it having to be particularly accurate... so in those occasions its probably best to go with simplicity rather than using a method that consumes more cpu.

But yea, i know it'd be stupid to code something like a "flash clock" using that code, but that wasnt the crux of my original question.

Response to AS: Timeouts 2005-09-09 11:50:24


you can change the frames per second with intervals
you can't change intervals with the frames per second

intervals and time outs are also more logic./

Response to AS: Timeouts 2005-09-18 08:12:33


This is wierd, setTimeout doesn't appear in blue as other commands do.. nor does it have any documentation at all. It works though, which is the wierdest thing.


Sup, bitches :)

BBS Signature

Response to AS: Timeouts 2005-09-18 08:13:43


At 9/18/05 08:12 AM, -liam- wrote: This is wierd, setTimeout doesn't appear in blue as other commands do.. nor does it have any documentation at all. It works though, which is the wierdest thing.

lool, i know that alot of things that are highlighted dont have documentation but not even being highlighted is a bit strange


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to AS: Timeouts 2005-10-04 17:58:14


what if i wanted it to just count the time for example at the end of my game it would say how long you played. also it would be helpfull if i could store it as a variable

Response to AS: Timeouts 2006-05-16 17:19:50


so when i have my bullet flying from a gun, how do i have my gun disabled for 2 seconds? Please answer, i'm currently spamming the NG BBS, which isn't working either :P

Thanks for the topic, Inglor

Response to AS: Timeouts 2009-02-21 01:40:03


Thanks!

This is good for HP regenerate.

You can use this, it's pretty much what he posted, lol.

This is just a button, to test it out, but can use the on event clip thingy
on(release)
{

setTimeout(function () {
//this will add 1 point to the variable hp of the frame named hp
++_root.hp
//every 5 sec, duh, lol.
}, 5000);

}

good luck, thanks again author!

Response to AS: Timeouts 2009-02-21 01:52:36


Fuck, nevermind, that doesn't work.

Response to AS: Timeouts 2009-02-21 01:55:17


At 2/21/09 01:52 AM, genitalwart wrote: Fuck, nevermind, that doesn't work.

XD

Nice 3 year bump for nothing.


#include <stdio.h>

char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";

main() {printf(p,10,34,p,34,10);}

BBS Signature

Response to AS: Timeouts 2009-02-21 02:39:00


At 9/9/05 11:30 AM, T-H wrote:
At 9/9/05 11:28 AM, LEMITUDE wrote: a++;
if (a >= 2000){
do stuff
}
LOL that wouldnt time acturately at all sorry, timeout will likely use more cpu but it will actually time properly, what you just suggested is absurd.

Thanks for that Inglor.

you could do something like this:

var timer:Number = getTimer();
var timeWait:Number = 500; //how long you want the wait to be in miliseconds
if (getTimer()>timer+timewait) {
	timer = getTimer(); //if you want it to wait again
	//do stuff
}

AS2||AS3||Motox

Thanks to hdxmike for the sig :]

BBS Signature

Response to AS: Timeouts 2009-02-21 02:45:06


No, what I think he needs is setInterval(), that way it continually replenishes health, as he describes.


#include <stdio.h>

char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";

main() {printf(p,10,34,p,34,10);}

BBS Signature