Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created July 17, 2010 12:49
Embed
What would you like to do?
package com.tommedema;
import haxe.Timer;
class DynamicTimer extends Timer
{
private var newTimer:Timer;
public function new(interval_ms:Int)
{
super(interval_ms);
}
public function restart(interval_ms:Int)
{
this.stop();
newTimer = new Timer(interval_ms);
newTimer.run = this.run;
}
public override function stop():Void {
if (newTimer == null) {
super.stop();
}
else {
newTimer.stop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment