Flow > Time


Delayed

Do after N seconds

do after number seconds

Runs the code after the given delay (in seconds, can be partial seconds).

runLater(1000 * [NUMBER], function(task:TimedTask):Void {
  [ACTIONS]
}, [ACTOR]);

Warning: Do not use this block in a when updating event, unless constrained by an if block or other conditional.


Periodic

Do every N seconds

do every number seconds

Runs the code every [N] seconds (can be partial seconds).

runPeriodically(1000 * [NUMBER], function(task:TimedTask):Void {
  [ACTIONS]
}, [ACTOR]);

Warning: Do not use this block in a when updating event, unless constrained by an if block or other conditional.

Example

time-example

do after n seconds and do every n seconds can be combined together. In this example, we implement a "blinking" effect by alternating the actor between hidden and not-hidden, without relying on a variable to store state.


Cancel

cancel

Cancels the execution of a periodic (do every n seconds) task.

timeTask.repeats = false;
return;