Adobe AIR native extension

Access to application options and device information

The extension is available here: com.distriqt.Application


The orientation of the device is sometimes important to applications, irrespective of the orientation of the UI. The DeviceOrientationEvent will give you information about the orientation of the device even if your UI doesn’t change.

This can be useful in situations when you have locked your UI to an aspect ratio but still want to react to the user rotating their device.

Listening for orientation changes

Listening for changes is as simple as adding a listener for the DeviceOrientationEvent.CHANGED event.

Application.service.device.addEventListener( DeviceOrientationEvent.CHANGED, orientationChangedHandler );

Then in your event handler you can respond to the orientation change appropriately:

private function orientationChangedHandler( event:DeviceOrientationEvent ):void
	trace( "orientationChangedHandler(): " + event.orientation );
	switch (event.orientation)
		case DeviceOrientation.DEFAULT:
		case DeviceOrientation.UPSIDE_DOWN:
		case DeviceOrientation.ROTATED_LEFT:
		case DeviceOrientation.ROTATED_RIGHT:

Starting orientation events

By default orientation events are not dispatched. This is due to a small amount of monitoring that is required to detect these changes.

To start generating orientation events you must call the startGeneratingDeviceOrientationEvents function:


Conversely if you wish to stop the events you can call stopGeneratingDeviceOrientationEvents: