Stopwatch
Kind of class: | class |
---|---|
Inherits from: | CoreObject |
Implements: | |
Known subclasses: | |
Version: | 06/11/07 |
Author: | Aaron Clinger |
Classpath: | org.casalib.time.Stopwatch |
File last modified: | Monday, 01 December 2008, 13:34:40 |
Simple stopwatch class that records elapsed time in milliseconds.
Example:
-
var stopwatch:Stopwatch = new Stopwatch(); this.start_mc.onPress = function():Void { this._parent.stopwatch.start(); trace("Stopwatch started."); } this.stop_mc.onPress = function():Void { this._parent.stopwatch.stop(); trace("Stopwatch stopped. Time elapsed: " + this._parent.stopwatch.getTime()); } this.resume_mc.onPress = function():Void { this._parent.stopwatch.resume(); trace("Stopwatch continued."); }
Summary
Constructor
Instance methods
- start : Void
- Starts stopwatch and resets previous elapsed time.
- stop : Void
- Stops stopwatch.
- resume : Void
- Resumes stopwatch from stop.
- getTime : Number
- Gets the time elapsed since start or until stop was called.
- destroy : Void
- Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.Instance methods inherited from CoreObject
Constructor
Stopwatch
function Stopwatch (
)
Instance methods
destroy
function destroy (
) : Void
Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.
Always call
# Always call
var stopwatch:Stopwatch = new Stopwatch(); this.start_mc.onPress = function():Void { this._parent.stopwatch.start(); trace("Stopwatch started."); } this.stop_mc.onPress = function():Void { this._parent.stopwatch.stop(); trace("Stopwatch stopped. Time elapsed: " + this._parent.stopwatch.getTime()); } this.resume_mc.onPress = function():Void { this._parent.stopwatch.resume(); trace("Stopwatch continued."); }before deleting last object pointer.
Overrides:
Specified by:
getTime
function getTime (
) : Number
Returns:
- Returns the elapsed time in milliseconds.
Usage note:
- Can be called before or after calling stop.
start
function start (
) : Void
Starts stopwatch and resets previous elapsed time.
Specified by:
stop
function stop (
) : Void
Stops stopwatch.
Specified by: