Documentation

HDTimer

The HDTimer object triggers an event after a configurable elapsed time. The event can also be repeated, so the event is triggered continuously.

By setting the object's properties, either at design-time in Handheld Designer, or at run-time in code, you can:

  • Set the timer's interval with the interval property.
  • Start or stop the timer with the enabled property.

Example:

// Start the timer
timer1.interval = 30;
timer1.enabled = true;

For more detail, view the full object documentation on HandheldDesigner.com.

Object Properties & Methods

 enabledDetermines whether the HDTimer object triggers its event.
 idThe object's unique identifier. Also used as the variable name in code.
 intervalThe number of milliseconds that elapse between triggering of the timer event.
 onTimeoutEvent that occurs when the timer's elapsed time expires.
 userdataAn object for storing user data.

enabled

PropertyFirst available in version 1.0.0

Determines whether the HDTimer object triggers its event.

Example:

// prevent the HDTimer object from triggering future events
timer1.enabled = false;

id

PropertyFirst available in version 1.0.0

The object's unique identifier. Also used as the variable name in code.

Example:

// get height of object with the id "object1".
var h = object1.height;

interval

PropertyFirst available in version 1.0.0

The number of milliseconds that elapse between triggering of the HDTimer event.

Example:

// set the HDTimer object to fire its event once every three seconds
timer1.interval = 3000;

onTimeout

EventFirst available in version 1.0.0

Event that occurs the when timer's elapsed time expires. The property is set by selecting an HDFunction object within Handheld Designer, or defined at runtime.

In code, the property can be set to reference an existing function:

timer1.onTimeout = someExistingFunction;

Or, you can define an anonymous function containing the code to be executed by the event:

// Move object1 down each time the timer event is triggered.
timer1.onTimeout = function(event) {
	object1.top = object1.top + 10;
};

userdata

PropertyFirst available in version 1.0.0

An JavaScript object for storing user data. You can use this property to store data for later use. (For example, to share data between event handlers.)

Example:

// track the number of times a button is clicked:
function button1_onClick(event) {
	if(button1.userdata.timesClicked === undefined)
	{
		button1.userdata.timesClicked = 0;
	}
	else
	{
		button1.userdata.timesClicked++;
	}
}

Copyright © 2010-2017, Handheld Designer, LLC, All Rights Reserved.
Made by hand in New England, USA.