flash.events

# StageOrientationEvent - AS3

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

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

A Stage object dispatches a StageOrientationEvent object when the orientation of the stage changes. This can occur when the device is rotated, when the user opens a slide-out keyboard, or when the `setAspectRatio()` method of the Stage is called.

There are two types of StageOrientationEvent event: The `orientationChanging` (`StageOrientationEvent.ORIENTATION_CHANGING`), is dispatched before the screen changes to a new orientation. Calling the `preventDefault()` method of the event object dispatched for orientationChanging prevents the stage from changing orientation. The `orientationChange` (`StageOrientationEvent.ORIENTATION_CHANGE`), is dispatched after the screen changes to a new orientation.

Note: If the `autoOrients` property is `false`, then the stage orientation does not change when a device is rotated. Thus, StageOrientationEvents are only dispatched for device rotation when `autoOrients` is `true`.

Learn more

Automatic orientation

Related API Elements

Stage.deviceOrientation
Stage.autoOrients

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | afterOrientation : String [read-only] The orientation of the stage after the change. | StageOrientationEvent
|  | beforeOrientation : String [read-only] The orientation of the stage before the change. | StageOrientationEvent
|  | 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
|  | type : String [read-only] The type of event. | Event

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | StageOrientationEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, beforeOrientation:String = null, afterOrientation:String = null) Creates a StageOrientationEvent object with specific information relevant to stage orientation events. | StageOrientationEvent
|  | clone():Event [override] Creates a copy of the StageOrientationEvent object and sets the value of each property to match that of the original. | StageOrientationEvent
|  | 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 StageOrientationEvent object. | StageOrientationEvent
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Public Constants
Hide Inherited Public Constants
Show Inherited Public Constants

| Constant | Defined By
--- | --- | ---
|  | ORIENTATION_CHANGE : String = "orientationChange" [static] The ORIENTATION_CHANGE constant defines the value of the type property of a orientationChange event object. | StageOrientationEvent
|  | ORIENTATION_CHANGING : String = "orientationChanging" [static] The ORIENTATION_CHANGING constant defines the value of the type property of a orientationChanging event object. | StageOrientationEvent

Property Detail

### afterOrientation

property

`afterOrientation:String` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

The orientation of the stage after the change.

Implementation
`public function get afterOrientation():String`

### beforeOrientation

property

`beforeOrientation:String` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

The orientation of the stage before the change.

Implementation
`public function get beforeOrientation():String`
Constructor Detail

### StageOrientationEvent

()
Constructor

`public function StageOrientationEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, beforeOrientation:String = null, afterOrientation:String = null)`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

Creates a StageOrientationEvent object with specific information relevant to stage orientation events. Event objects are passed as parameters to event listeners. Generally you do not create this event using the constructor function. Instead, you add an event listener on the Stage object to detect these events as they occur.

Parameters

| `type:String` — The type of the event: `StageOrientationEvent.ORIENTATION_CHANGE`
| `bubbles:Boolean` (default = `false`)`` — Indicates whether the Event object participates in the bubbling stage of the event flow.
| `cancelable:Boolean` (default = `false`)`` — Indicates whether the Event object can be canceled.
| `beforeOrientation:String` (default = `null`)`` — Indicates the orientation before the change.
| `afterOrientation:String` (default = `null`)`` — Indicates the orientation after the change.

Method Detail

### clone

()
method

`override public function clone():Event`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

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

Returns

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

### toString

()
method

`override public function toString():String`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

Returns a string that contains all the properties of the StageOrientationEvent object. The string has the following format:

`[StageOrientationEvent type=value bubbles=value cancelable=value beforeDisplayState=value afterDisplayState=value]`

Returns

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

Constant Detail

### ORIENTATION_CHANGE

Constant

`public static const ORIENTATION_CHANGE:String = "orientationChange"`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

The `ORIENTATION_CHANGE` constant defines the value of the `type` property of a `orientationChange` event object. This event has the following properties:

Properties | Values
--- | ---
`afterOrientation` | The new orientation of the stage.
`beforeOrientation` | The old orientation of the stage.
`target` | The Stage object that dispatched the orientation change.
`bubbles` | `true`
`currentTarget` | Indicates the object that is actively processing the Event object with an event listener.
`cancelable` | `false`; it is too late to cancel the change.

Related API Elements

flash.display.Stage
deviceOrientation

### ORIENTATION_CHANGING

Constant

`public static const ORIENTATION_CHANGING:String = "orientationChanging"`

Language Version: | ActionScript 3.0

Runtime Versions: | AIR 2

The `ORIENTATION_CHANGING` constant defines the value of the `type` property of a `orientationChanging` event object.

Important: ORIENTATION_CHANGING events are not dispatched on Android devices.

This event has the following properties:

Properties | Values
--- | ---
`afterOrientation` | The new orientation of the stage.
`beforeOrientation` | The old orientation of the stage.
`target` | The Stage object that dispatched the orientation change.
`bubbles` | `true`
`currentTarget` | Indicates the object that is actively processing the Event object with an event listener.
`cancelable` | `true`.

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