Bill
Bill

Reputation: 19268

AS3 StageOrientationEvent.ORIENTATION_CHANGING not work on iPad3 iOS6

any idea why my code is not working on iPad3 iOS6, or is it a bug of Adobe air?

The following code work for iPad1 and iPad2 with iOS5

            if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN){
                stage.setOrientation(StageOrientation.ROTATED_RIGHT);}
            else{
                stage.setOrientation(startOrientation);
            }           

            stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);

private function orientationChangeListener(e:StageOrientationEvent):void{
            txt_rotate.text = 'Camed' + StageOrientation.ROTATED_LEFT;
           if (e.afterOrientation == StageOrientation.DEFAULT || e.afterOrientation ==  StageOrientation.UPSIDE_DOWN){
                e.preventDefault();
           }else if(e.afterOrientation ==  StageOrientation.ROTATED_LEFT){
               _stageOrientation = 'ROTATED_LEFT';
               txt_rotate.text = _stageOrientation;
           }else if(e.afterOrientation ==  StageOrientation.ROTATED_RIGHT){
               _stageOrientation = 'ROTATED_RIGHT';
               txt_rotate.text = _stageOrientation;
           }
        }

Upvotes: 1

Views: 1393

Answers (1)

Elic Ng
Elic Ng

Reputation: 46

Apple made some modifications in orientation callbacks in iOS6 SDK, thus rendering some functions deprecated.

preventDefault function will not work on StageOrientationEvent. It is recommended to use Stage.autoOrients to false when needed.

http://blogs.adobe.com/airodynamics/2012/09/28/orientation-changes-in-air/

Upvotes: 2

Related Questions