flash.events

# AccelerometerEvent - AS3

Package | flash.events
Class | public class AccelerometerEvent
Inheritance | AccelerometerEvent Event Object

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

The Accelerometer class dispatches AccelerometerEvent objects when acceleration updates are obtained from the Accelerometer sensor installed on the device.

Related API Elements

flash.sensors.Accelerometer

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | accelerationX : Number Acceleration along the x-axis, measured in Gs. | AccelerometerEvent
|  | accelerationY : Number Acceleration along the y-axis, measured in Gs. | AccelerometerEvent
|  | accelerationZ : Number Acceleration along the z-axis, measured in Gs. | AccelerometerEvent
|  | bubbles : Boolean [read-only] Indicates whether an event is a bubbling event. | Event
|  | cancelable : Boolean [read-only] Indicates whether the behavior associated with the event can be prevented. | Event
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | currentTarget : Object [read-only] The object that is actively processing the Event object with an event listener. | Event
|  | eventPhase : uint [read-only] The current phase in the event flow. | Event
|  | target : Object [read-only] The event target. | Event
|  | timestamp : Number The number of milliseconds at the time of the event since the runtime was initialized. | AccelerometerEvent
|  | type : String [read-only] The type of event. | Event

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | AccelerometerEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, timestamp:Number = 0, accelerationX:Number = 0, accelerationY:Number = 0, accelerationZ:Number = 0) Creates an AccelerometerEvent object that contains information about acceleration along three dimensional axis. | AccelerometerEvent
|  | clone():Event [override] Creates a copy of an AccelerometerEvent object and sets the value of each property to match that of the original. | AccelerometerEvent
|  | formatToString(className:String, ... arguments):String A utility function for implementing the toString() method in custom ActionScript 3.0 Event classes. | Event
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isDefaultPrevented():Boolean Checks whether the preventDefault() method has been called on the event. | Event
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | preventDefault():void Cancels an event's default behavior if that behavior can be canceled. | Event
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | stopImmediatePropagation():void Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. | Event
|  | stopPropagation():void Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. | Event
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String [override] Returns a string that contains all the properties of the AccelerometerEvent object. | AccelerometerEvent
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Public Constants
Hide Inherited Public Constants
Show Inherited Public Constants

| Constant | Defined By
--- | --- | ---
|  | UPDATE : String = "update" [static] Defines the value of the type property of a AccelerometerEvent event object. | AccelerometerEvent

Property Detail

### accelerationX

property

`accelerationX:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

Acceleration along the x-axis, measured in Gs. (1 G is roughly 9.8 m/sec/sec.) The x-axis runs from the left to the right of the device when it is in the upright position. The acceleration is positive if the device moves towards the right.

Implementation
`public function get accelerationX():Number`
`public function set accelerationX(value:Number):void`

### accelerationY

property

`accelerationY:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

Acceleration along the y-axis, measured in Gs. (1 G is roughly 9.8 m/sec/sec.). The y-axis runs from the bottom to the top of the device when it is in the upright position. The acceleration is positive if the device moves up relative to this axis.

Implementation
`public function get accelerationY():Number`
`public function set accelerationY(value:Number):void`

### accelerationZ

property

`accelerationZ:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

Acceleration along the z-axis, measured in Gs. (1 G is roughly 9.8 m/sec/sec.). The z-axis runs perpendicular to the face of the device. The acceleration is positive if you move the device so that the face moves higher.

Implementation
`public function get accelerationZ():Number`
`public function set accelerationZ(value:Number):void`

### timestamp

property

`timestamp:Number`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

The number of milliseconds at the time of the event since the runtime was initialized. For example, if the device captures accelerometer data 4 seconds after the application initializes, then the `timestamp` property of the event is set to 4000.

Implementation
`public function get timestamp():Number`
`public function set timestamp(value:Number):void`
Constructor Detail

### AccelerometerEvent

()
Constructor

`public function AccelerometerEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, timestamp:Number = 0, accelerationX:Number = 0, accelerationY:Number = 0, accelerationZ:Number = 0)`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

Creates an AccelerometerEvent object that contains information about acceleration along three dimensional axis. Event objects are passed as parameters to event listeners.

Parameters

| `type:String` — The type of the event. Event listeners can access this information through the inherited `type` property. There is only one type of update event: `AccelerometerEvent.UPDATE`.
| `bubbles:Boolean` (default = `false`)`` — Determines whether the Event object bubbles. Event listeners can access this information through the inherited `bubbles` property.
| `cancelable:Boolean` (default = `false`)`` — Determines whether the Event object can be canceled. Event listeners can access this information through the inherited `cancelable` property.
| `timestamp:Number` (default = `0`)`` — The timestamp of the Accelerometer update.
| `accelerationX:Number` (default = `0`)`` — The acceleration value in Gs (9.8m/sec/sec) along the x-axis.
| `accelerationY:Number` (default = `0`)`` — The acceleration value in Gs (9.8m/sec/sec) along the y-axis.
| `accelerationZ:Number` (default = `0`)`` — The acceleration value in Gs (9.8m/sec/sec) along the z-axis.

Method Detail

### clone

()
method

`override public function clone():Event`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1

Creates a copy of an AccelerometerEvent object and sets the value of each property to match that of the original.

Returns

| `Event` — A new AccelerometerEvent object with property values that match those of the original.

### toString

()
method

`override public function toString():String`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 9, AIR 2, Flash Player 10.1

Returns a string that contains all the properties of the AccelerometerEvent object. The following format is used:

`[AccelerometerEvent type=value bubbles=value cancelable=value timestamp=value accelerationX=value accelerationY=value accelerationZ=value ]`

Returns

| `String` — A string that contains all the properties of the AccelerometerEvent object.

Constant Detail

### UPDATE

Constant

`public static const UPDATE:String = "update"`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2, Flash Player 10.1, Flash Lite 4

Defines the value of the `type` property of a `AccelerometerEvent` event object.

This event has the following properties:

Property | Value
--- | ---
`bubbles` | `false`
`cancelable` | `false`; there is no default behavior to cancel.
`currentTarget` | The object that is actively processing the Event object with an event listener.
`timestamp` | The timestamp of the Accelerometer update.
`accelerationX` | The acceleration value in Gs (9.8m/sec/sec) along the x-axis.
`accelerationY` | The acceleration value in Gs (9.8m/sec/sec) along the y-axis.
`accelerationZ` | The acceleration value in Gs (9.8m/sec/sec) along the z-axis.

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00