Calculating and showing an elapsed time

MINI LESSONS ››

MINI LESSON

CALCULATING AND SHOWING ELAPSED TIME

The ability to calculate and show elapsed time is something that can be achieved by using an Action Timer catalog object and some Actions Editor programming logic.


This mini-lesson is intended to expose this feature to you so that you can then utilize it in your own specific way.


 


OVERVIEW

The basic idea is to implement the following:


  1. Start the Action Timer when you are ready to start measuring elapsed time. This could be as a certain page loads, or even when clicking on an object.
  2. Every 100 milliseconds allow the timer to calculate the current elapsed time
  3. Place the elapsed time into a field on the page so that the user can see the value


DETAILS

The Action Timer object can be found in the Action Objects category of the catalog. This object is the key here. It has the ability to count up (called a Time of Day timer) or down (Countdown timer).


Timer Object

For the purposes of this example the Time of Day timer is used and is set to a Periodic value of 100 ms.


 


Programming Logic

Using the Actions Editor, logic can be added to the On Media Timing Event for the Action Timer object. This event is sent to the Action Timer object every 100 ms (because this was set up for a Periodic value of 100 ms above). This means that every 1/10th of a second the timer checks to see if anything needs to be done.


There is one Parameter accessible within this event called mediaPosition. This value is the current timer value at the moment the event is triggered.


For those interested, this value is actually the number of milliseconds which have elapsed from January 1, 1970.


The logic seen below uses a few variables.


 

Global Variables

Local Variable



Created with the Personal Edition of HelpNDoc: Free PDF documentation generator