Created
July 18, 2011 09:24
-
-
Save skyboy/1088992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Time { | |
import flash.utils.getQualifiedClassName; | |
public static const TIME_IS_INTRINSIC:int = 0; | |
public static const TIME_IS_EXTRINSIC:int = 1; | |
private static const CLASSNAME:String = getQualifiedClassName(new Time()); | |
protected var paused:Boolean; | |
protected var lastTime:uint; | |
protected var accumulated:uint; | |
public function Time():void { | |
if (getQualifiedClassName(this) == CLASSNAME) throw new Error("Not allowed to instaniate abstract " + CLASSNAME + " object."); | |
} | |
public function get now():uint { | |
if (!paused) lastTime = getTimer() - accumulated; | |
else accumulated = getTimer() - lastTime; | |
return lastTime; | |
} | |
public function pause():void { paused = true; } | |
public function resume(timeMult:int):void { | |
throw new Error("Method \"resume\" must be defined by child classes."); | |
} | |
public function get tick():ISignal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment