Guest User

Untitled

a guest
Feb 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class Time {
  2. import flash.utils.getQualifiedClassName;
  3. public static const TIME_IS_INTRINSIC:int = 0;
  4. public static const TIME_IS_EXTRINSIC:int = 1;
  5.  
  6. private static const CLASSNAME:String = getQualifiedClassName(new Time());
  7.  
  8. protected var paused:Boolean;
  9. protected var lastTime:uint;
  10. protected var accumulated:uint;
  11.  
  12. public function Time():void {
  13. if (getQualifiedClassName(this) == CLASSNAME) throw new Error("Not allowed to instaniate abstract " + CLASSNAME + " object.");
  14. }
  15.  
  16. public function get now():uint {
  17. if (!paused) lastTime = getTimer() - accumulated;
  18. else accumulated = getTimer() - lastTime;
  19. return lastTime;
  20. }
  21.  
  22. public function pause():void { paused = true; }
  23.  
  24. public function resume(timeMult:int):void {
  25. throw new Error("Method \"resume\" must be defined by child classes.");
  26. }
  27.  
  28. public function get tick():ISignal;
  29. }
Add Comment
Please, Sign In to add comment