Package | com.eqsim.components |
Class | public class Stopwatch |
Inheritance | Stopwatch ![]() |
This class implements a stopwatch that can be started, paused, and reset.
It does not subclass timer, it just uses a timer object. The resolution
property
is the resolution of the stopwatch (minimum value for checking if time has elapsed). When you
need to optimize precision, you should adjust resolution
to a resolution that is at most half of
the shortest interval you need to measure.
The class has one event, by default called "onPulse" (but this can
be changed in the component parameter panel, or programmatically by setting evtPulse
).
Property | Defined By | ||
---|---|---|---|
active : Boolean
Set this value to start or stop the timing interval. | Stopwatch | ||
evtPulse : String = onPulse
This property holds the string name of the event. | Stopwatch | ||
pulseInterval : int
This property indicates the interval at which to generate pulse events when the stopwatch is active. | Stopwatch | ||
_resolution : int = 100 | Stopwatch | ||
resolution : int
This property holds the resolution of the timer. | Stopwatch |
Property | Defined By | ||
---|---|---|---|
goQuietly : Boolean | Stopwatch | ||
_lastTime : int | Stopwatch | ||
_oldVal : int | Stopwatch | ||
origHeight : Number | Stopwatch | ||
origWidth : Number | Stopwatch | ||
previewBox : MovieClip | Stopwatch | ||
st : SimpleTimer | Stopwatch | ||
StopwatchPreviewClip : Class | Stopwatch | ||
_val : int | Stopwatch |
Method | Defined By | ||
---|---|---|---|
Stopwatch | |||
destroy():void
Remove this component's associated listeners and memory. | Stopwatch | ||
getTime():Number
Retrieve the current time of the stopwatch. | Stopwatch | ||
pause():void
Pause the stopwatch. | Stopwatch | ||
reset():void
Reset the stopwatch. | Stopwatch | ||
start():void
Activate the stopwatch. | Stopwatch |
Method | Defined By | ||
---|---|---|---|
configUI():void [override]
configUI
Get the display objects created in preparation of launch. | Stopwatch | ||
draw():void [override]
| Stopwatch | ||
resetStopwatchParameters():void
Called when someone has changed a stopwatch parameter. | Stopwatch | ||
timerElapsed(te:EventWithData):void
This is called on timer interrupts. | Stopwatch |
Event | Summary | Defined By | ||
---|---|---|---|---|
Event generated at a user-controllable interval while the stopwatch is running. | Stopwatch |
_lastTime | property |
protected var _lastTime:int
_oldVal | property |
protected var _oldVal:int
_resolution | property |
public var _resolution:int = 100
_val | property |
protected var _val:int
active | property |
active:Boolean
Set this value to start or stop the timing interval. If changed while the timer is active, the timer resets and starts again.
public function get active():Boolean
public function set active(value:Boolean):void
evtPulse | property |
public var evtPulse:String = onPulse
This property holds the string name of the event.
goQuietly | property |
protected var goQuietly:Boolean
origHeight | property |
protected var origHeight:Number
origWidth | property |
protected var origWidth:Number
previewBox | property |
protected var previewBox:MovieClip
pulseInterval | property |
pulseInterval:int
This property indicates the interval at which to generate pulse events when the stopwatch is active. Use 0 to mean don't generate pulses at all.
public function get pulseInterval():int
public function set pulseInterval(value:int):void
resolution | property |
resolution:int
This property holds the resolution of the timer. This must be set to the pulse interval at the maximum. It determines how often we check to see that the stopwatch has advanced.
public function get resolution():int
public function set resolution(value:int):void
st | property |
protected var st:SimpleTimer
StopwatchPreviewClip | property |
protected var StopwatchPreviewClip:Class
Stopwatch | () | Constructor |
public function Stopwatch()
configUI | () | method |
override protected function configUI():void
configUI Get the display objects created in preparation of launch. Note that we get called before our constructor, and before we are notified that we are on the stage!
destroy | () | method |
public function destroy():void
Remove this component's associated listeners and memory.
draw | () | method |
override protected function draw():void
getTime | () | method |
public function getTime():Number
Retrieve the current time of the stopwatch.
ReturnsNumber |
pause | () | method |
public function pause():void
Pause the stopwatch.
reset | () | method |
public function reset():void
Reset the stopwatch.
resetStopwatchParameters | () | method |
protected function resetStopwatchParameters():void
Called when someone has changed a stopwatch parameter. If the stopwatch is running, we pause it, reset the values, then restart. If the stopwatch is not active, we don't need to do anything (parameters are set outside us).
start | () | method |
public function start():void
Activate the stopwatch.
timerElapsed | () | method |
protected function timerElapsed(te:EventWithData):void
This is called on timer interrupts. Decide if we should issue a pulse.
Parameters
te:EventWithData |
onPulse | Event |
Event generated at a user-controllable interval while the stopwatch is running.