Canceling a schedule
by baylor wetzel · in Torque Game Builder · 09/19/2009 (8:54 pm) · 4 replies
How do you cancel a schedule? i thought it was "cancel" but that doesn't seem to work
function AnimationHandler::stop(%this)
{
warn("AnimationHandler::stop() - %this.currentSchedule = " @ %this.currentSchedule);
cancel(%this.currentSchedule);
warn(" schedule is now " @ %this.currentSchedule);
warn(" canceled the schedule, better not happen again");
%this.currentSchedule = "";
}
function AnimationHandler::onFrameChange(%this)
{
%this.currentSchedule = %this.schedule(%frame.displayTime, onFrameChange);
}About the author
#2
* check if event is pending with "isEventPending" function
* if that's real piece of your code (without some removals) then %frame variable is uninitialized and thus %frame.displayTime returns 0 (zero) so scheduled event fires immediately after onFrameChange quits
09/22/2009 (1:01 pm)
Two points:* check if event is pending with "isEventPending" function
* if that's real piece of your code (without some removals) then %frame variable is uninitialized and thus %frame.displayTime returns 0 (zero) so scheduled event fires immediately after onFrameChange quits
#3
@Steve, the function "cancel" does not work, at least not when used with the object method version of schedule, as shown in the code in the original post
09/22/2009 (2:50 pm)
@World-Loom, you are correct, there was code removed to make the code sample shorter. i have bunches of echoes that verify the status of the event and the other parts of the code. Everything runs fine with the exception that cancel does not cancel@Steve, the function "cancel" does not work, at least not when used with the object method version of schedule, as shown in the code in the original post
#4
09/22/2009 (5:12 pm)
Assuming %this.currentSchedule is valid then cancel(%this.currentSchedule) should work. There is only one version of cancel and it works regardless of the version of schedule used.
Torque Owner Steve D
$schedule = schedule(1000,0, "myfunction");
cancel($schedule);