egret.StageOrientationEvent
包 egret
类 public class StageOrientationEvent
继承 egret.StageOrientationEvent → egret.Event → egret.HashObject
当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。
公共属性
| 属性 | 
|---|
| ORIENTATION_CHANGE : string [静态]屏幕旋转后派发的事件 | 
公共方法
| 方法 | 
|---|
| StageOrientationEvent(type:string,bubbles:boolean,cancelable:boolean) 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象 | 
| dispatchStageOrientationEvent(target:egret.IEventDispatcher,type:string):boolean [静态]派发一个屏幕旋转的事件 | 
属性详细信息
ORIENTATION_CHANGE
ORIENTATION_CHANGE : string = "orientationChange"
- 支持版本:Egret 2.4
- 运行平台:Web,Native
屏幕旋转后派发的事件。
方法详细信息
StageOrientationEvent()
public StageOrientationEvent(type:string,bubbles:boolean,cancelable:boolean)
创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。
- 支持版本:Egret 2.4
- 运行平台:Web,Native
- 参数
dispatchStageOrientationEvent()
public dispatchStageOrientationEvent(target:egret.IEventDispatcher,type:string):boolean
派发一个屏幕旋转的事件。
- 支持版本:Egret 2.4
- 运行平台:Web,Native
- 参数- target:egret.IEventDispatcher - Distribute event target
- type:string - Distribute event type
 
示例
/*
 * 以下示例演示了舞台方向旋转变化事件的使用。
 */
class  StageOrientationEventExample  extends  egret.DisplayObjectContainer  {
  private text: egret.TextField;
  public  constructor()  {
    super();
    this.once(egret.Event.ADDED_TO_STAGE,  this.onAddStage,  this);
  }
  private  onAddStage():  void  {
    this.text  =  new  egret.TextField();
    this.text.text  =  "Text init.";
    this.text.x  =  50;
    this.text.y  =  100;
    this.addChild(this.text);
    this.stage.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,  this.onOrientationChange,  this);
  }
  private  onOrientationChange(e: egret.StageOrientationEvent):  void  {
    egret.log("onOrientationChange");
    this.text.text  =  "onOrientationChange";
  }
}

