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

StageOrientationEvent  - AS3

Packageflash.events
Classpublic class StageOrientationEvent
InheritanceStageOrientationEvent Inheritance Event Inheritance 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

Related API Elements



Public Properties
 PropertyDefined 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
 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
 Inheritedtype : String
[read-only] The type of event.
Event
Public Methods
 MethodDefined 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
 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
  
    toString():String
[override] Returns a string that contains all the properties of the StageOrientationEvent object.
StageOrientationEvent
 Inherited
Returns the primitive value of the specified object.
Object
Public Constants
 ConstantDefined 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:

PropertiesValues
afterOrientationThe new orientation of the stage.
beforeOrientationThe old orientation of the stage.
targetThe Stage object that dispatched the orientation change.
bubblestrue
currentTargetIndicates the object that is actively processing the Event object with an event listener.
cancelablefalse; it is too late to cancel the change.

Related API Elements

    

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:
PropertiesValues
afterOrientationThe new orientation of the stage.
beforeOrientationThe old orientation of the stage.
targetThe Stage object that dispatched the orientation change.
bubblestrue
currentTargetIndicates the object that is actively processing the Event object with an event listener.
cancelabletrue.