search

Class myphysicslab.lab.util.ClockTask

Provided By

Holds a callback function to be executed at a specified time; used with myphysicslab.lab.util.Clock. ClockTasks are scheduled as a side effect of Clock methods such as setTime(), resume(), addTask(). ClockTasks are cancelled as a side effect of Clock methods such as pause(), removeTask().

See Clock section Types of Time about clock time and system time.

Here is an example of setting up a ClockTask that pauses the Clock after 5 seconds. This can be entered in myphysicslab.lab.util.Terminal if using simple-compile.

var task = new ClockTask(5, function() { clock.pause(); });
clock.addTask(task);

Here is an example of a ClockTask that resets the simulation every 15 seconds. This can be entered in Terminal if using simple-compile.

var redo = function() { sim.reset(); };
clock.addTask(new ClockTask(15, redo));

new ClockTask( time, callBack )

Parameters
timenumber

the clock time in seconds when the callBack should start

callBackfunction(): *

the function to execute at the given clock time

Instance Methods