| Platform | Since |
|---|---|
| Android | 0.1 |
| iPhone | 0.1 |
| iPad | 0.1 |
| Mobile Web | 1.8 |
The top level Accelerometer module. The Accelerometer modules contains methods and properties for using the device accelerometer.
You'll want to be selective about turning on and off the device accelerometer. It's recommended you turn off the accelerometer when you're not using it.
You can turn off the accelerometer by simply removing your event listener function.
Titanium.Accelerometer.removeEventListener('update',myFunction);
You can turn it back on by re-adding the same function with addEventListener.
Adds an accelerometer update event listener which prints out the x, y and z axis as the device is moved. You should generally remove the event when not used to conserve device resources. If you do not have an active event listener, the accelerometer is turned off to conserve device resources.
Titanium.Accelerometer.addEventListener('update',function(e) { Ti.API.debug("accelerometer - x:"+e.x+",y:"+e.y+",z:"+e.z); });
| Name | Summary |
|---|---|
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| Name | Summary |
|---|---|
| update |
fired when the accelerometer changes |