class Accelerometer
package openfl.sensors
extends EventDispatcher
Available on all platforms
The Accelerometer class dispatches events based on activity detected by the device's motion sensor. This data represents the device's location or movement along a 3-dimensional axis. When the device moves, the sensor detects this movement and returns acceleration data. The Accelerometer class provides methods to query whether or not accelerometer is supported, and also to set the rate at which acceleration events are dispatched.
Note: Use the Accelerometer.isSupported
property to
test the runtime environment for the ability to use this feature. While the
Accelerometer class and its members are accessible to the Runtime Versions
listed for each API entry, the current environment for the runtime
determines the availability of this feature. For example, you can compile
code using the Accelerometer class properties for Flash Player 10.1, but
you need to use the Accelerometer.isSupported
property to test
for the availability of the Accelerometer feature in the current deployment
environment for the Flash Player runtime. If
Accelerometer.isSupported
is true
at runtime,
then Accelerometer support currently exists.
OpenFL target support: This feature is supported on mobile targets, including iOS and Android, and on the html5 target in browsers that support the devicemotion event. This feature is not supported on desktop targets.
Adobe AIR profile support: This feature is supported only on mobile devices. It is not supported on desktop or AIR for TV devices. See AIR Profile Support for more information regarding API support across multiple profiles.
Events:
status | Dispatched when an accelerometer changes its status. Note: On some devices, the accelerometer is always
|
---|---|
update | The
|
Static variables
staticread onlyisSupported:Bool
The isSupported
property is set to true
if the
accelerometer sensor is available on the device, otherwise it is set to
false
.
Constructor
Variables
muted:Bool
Specifies whether the user has denied access to the accelerometer
(true
) or allowed access (false
). When this
value changes, a status
event is dispatched.
Methods
setRequestedUpdateInterval(interval:Int):Void
The setRequestedUpdateInterval
method is used to set the
desired time interval for updates. The time interval is measured in
milliseconds. The update interval is only used as a hint to conserve the
battery power. The actual time between acceleration updates may be greater
or lesser than this value. Any change in the update interval affects all
registered listeners. You can use the Accelerometer class without calling
the setRequestedUpdateInterval()
method. In this case, the
application receives updates based on the device's default interval.
Parameters:
interval | The requested update interval. If |
---|
Throws:
ArgumentError | The specified |
---|