ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
flash.events 

AccelerometerEvent  - AS3

Packageflash.events
Classpublic class AccelerometerEvent
InheritanceAccelerometerEvent Inheritance Event Inheritance 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



Public Properties
 PropertyDefined 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
 Inheritedbubbles : Boolean
[read-only] Indicates whether an event is a bubbling event.
Event
 Inheritedcancelable : Boolean
[read-only] Indicates whether the behavior associated with the event can be prevented.
Event
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 InheritedcurrentTarget : Object
[read-only] The object that is actively processing the Event object with an event listener.
Event
 InheritedeventPhase : uint
[read-only] The current phase in the event flow.
Event
 Inheritedtarget : 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
 Inheritedtype : String
[read-only] The type of event.
Event
Public Methods
 MethodDefined 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
  
[override] Creates a copy of an AccelerometerEvent object and sets the value of each property to match that of the original.
AccelerometerEvent
 Inherited
formatToString(className:String, ... arguments):String
A utility function for implementing the toString() method in custom ActionScript 3.0 Event classes.
Event
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Checks whether the preventDefault() method has been called on the event.
Event
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Cancels an event's default behavior if that behavior can be canceled.
Event
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow.
Event
 Inherited
Prevents processing of any event listeners in nodes subsequent to the current node in the event flow.
Event
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
  
[override] Returns a string that contains all the properties of the AccelerometerEvent object.
AccelerometerEvent
 Inherited
Returns the primitive value of the specified object.
Object
Public Constants
 ConstantDefined 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:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
timestampThe timestamp of the Accelerometer update.
accelerationXThe acceleration value in Gs (9.8m/sec/sec) along the x-axis.
accelerationYThe acceleration value in Gs (9.8m/sec/sec) along the y-axis.
accelerationZThe acceleration value in Gs (9.8m/sec/sec) along the z-axis.