Stopwatch

Kind of class:public class
Package:org.casalib.time
Inherits from:none
Implements:
Known subclasses:
Version:09/06/09
Author:Aaron Clinger, Mike Creighton
Classpath:org.casalib.time.Stopwatch
File last modified:Sunday, 06 September 2009, 08:45:49
Simple stopwatch class that records elapsed time in milliseconds.
Example:
  • package {
        import org.casalib.display.CasaMovieClip;
        import org.casalib.time.Stopwatch;
    
    
        public class MyExample extends CasaMovieClip {
    
            public function MyExample() {
                super();
    
                var stopwatch:Stopwatch = new Stopwatch();
                stopwatch.start();
    
                var l:uint = 1000000;
                while (l--) {
                    doSomething();
                }
    
                trace(stopwatch.time);
            }
    
            public function doSomething():void {
    
            }
        }
    }

Summary


Constructor
Instance properties
  • running : Boolean
    • Determines if the stopwatch is currently running true, or if it isn't false.
  • time : int
    • Gets the time elapsed since start or until stop was called.
Instance methods
  • start : void
    • Starts stopwatch and resets previous elapsed time.
  • stop : void
    • Stops stopwatch.
  • resume : void
    • Resumes stopwatch from stop.

Constructor

Stopwatch

public function Stopwatch (
)

Creates a new Stopwatch.

Instance properties

running

public running:Boolean
(read)

Determines if the stopwatch is currently running true, or if it isn't false.

time

public time:int
(read)

Gets the time elapsed since start or until stop was called.
Returns:
  • Returns the elapsed time in milliseconds.
Usage note:
  • Can be called before or after calling stop.

Instance methods

resume

public function resume (
) : void

Resumes stopwatch from stop.
Specified by:

start

public function start (
) : void

Starts stopwatch and resets previous elapsed time.
Specified by:

stop

public function stop (
) : void

Stops stopwatch.
Specified by: