Use the Timer object to trigger an Action Command after a specific amount of time has elapsed. You can use Timer objects to create simple slide shows and timed tests.


To create a Timer object, use the mouse to draw a rectangle where you would like the object to appear. (The placement of the Timer object is not critical, since it will not be visible when running the publication.) The Timer Properties screen will be displayed, allowing you to define the object’s behavior.


The Timer Properties screen is divided into two sections indicated by the icon images on the left: General and Actions. To view the settings for a section, click the corresponding icon.


General

Timer objects can be activated either manually or automatically. Enable the Automatically when page is displayed option to activate the Timer immediately whenever the page it’s on is displayed. Use this option when you want to give the reader a set amount of time to view a page before moving on. If Wait for “TimerStart” Action is selected, the Timer will remain inactive until it receives a TimerStart command. You might choose to have the Timer sit dormant until the reader clicks a Push Button or responds to a MessageBox. For example:


TimerStart "Timer1" "2000"


The Timer interval is specified in milliseconds (one-thousandth of a second). For a one second interval enter 1000 milliseconds. For one minute interval enter 60000 milliseconds. Once activated, this is the amount of time that will elapse before the Actions associated with the Timer are executed.



Once activated, a Timer will execute repeatedly until manually stopped or the publication shuts down. The assigned Action commands will be executed each time the timer’s interval is reached. If you only need the Timer’s Action to execute once, enable the Stop timer after one execution option. Alternatively, enabling the Stop timer when leaving page option will allow the Timer to run until the reader navigates from the current page.


If neither of the above stop options are enabled, you can deactivate the Timer manually using the TimerStop Action. For example:


TimerStop "Timer1"


You can use the Variable (to store elapsed time) to keep track of how many milliseconds the Timer has been running. To use this option, enter a variable name into the field. At runtime, this variable can be examined to determine how long the Timer has been running. This feature could be used to create a rudimentary stopwatch. For example, you could track how long a reader took to complete a test:


.convert the elapsed time from milliseconds to minutes

Math "[ElapsedTime] / 60000" "2" "[Score]"

AlertBox "Hello" "You took [Score] minutes to finish the test."


Actions

The Timer object supports only a single Action Event called Timer Interval. The Actions entered here will be executed when the Timer’s internal counter reaches the specified interval. (See Understanding Actions and Variables and Action Command Reference for a complete discussion of the Action Editor and Action Commands.) After the Actions have been executed, the Timer will be reset and begin counting from zero again unless it has been deactivated. If you do not want your Timer Action to execute more than once, include a TimerStop command in the Timer’s Action or use the Stop timer after one execution option.