Saturday, April 25, 2015

Flash AIR for Android default orientation 고정하기

app.xml
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>

private function onAddedToStage( event:Event ):void {
    stage.addEventListener( Event.RESIZE, onStageResize );
    NativeApplication.nativeApplication.addEventListener( Event.ACTIVATE, onNativeApplicationActivate );
}

private function onStageResize( event:Event ):void {
    checkForOrientationChange();
}

private function onNativeApplicationActivate( event:Event ):void {
    checkForOrientationChange();
}

private function checkForOrientationChange():void {
    if ( height > width ) {
        if ( stage ) {
            stage.setOrientation( StageOrientation.ROTATED_RIGHT );
        } else {
            // The first ACTIVATE event occurs before the Application has been added to the stage
            callLater( checkForOrientationChange );
        }
    }
}

No comments:

Post a Comment