11 Replies Latest reply on Jan 8, 2015 3:59 PM by Katush

    StageOrientation without device auto-orientation

    Katush Level 1

      There are lots of docs and posts online about being able to use StageOrientation without a device orientation itself having to change (disabling auto-orientation). I have tried autoOrients set to false and the alternative event.preventDefault ... but nothing works. Adobe Flash always changes the device orientation when I get StageOrientation.

       

      Is there a sample I can download? I have tried every publishing and Actionscript 3 setting/combination and it just isn't working. Auto orientation seems to be the only way to use StageOrientation.

       

      I am using latest Adobe Flash CC 2014 and can get the app to either auto orientate and show me the StageOrientation value, or lock the orientation and get not StageOrientation value. I tried this on a few ios devices and cannot get this working right. Please help.

        • 1. Re: StageOrientation without device auto-orientation
          kglad Adobe Community Professional & MVP

          what are you trying to do?

          • 2. Re: StageOrientation without device auto-orientation
            Katush Level 1

            Thanks for asking kglad. I don't like the choppy rotation effect of adobe Flash apps when ios device orientation is changed between landscape and portrait by default (they just aren't as smooth as native xcode apps), so wanted to keep orientation to either portrait or landscape (depending on the authoring orientation) and use StageOrientation to detect orientation to trigger a app container movieclip to rotate. I want full control of the animation when device orientation is change ... I just find the default behaviour jarring and drives me crazy.

            • 4. Re: StageOrientation without device auto-orientation
              Katush Level 1

              I couldn't get that working, no.

              • 5. Re: StageOrientation without device auto-orientation
                kglad Adobe Community Professional & MVP

                you can't set the stage orientation?

                 

                what code are you using?

                • 6. Re: StageOrientation without device auto-orientation
                  Katush Level 1

                  The docs say "In some cases you may want to disable auto-orientation to ... handle resizing the stage and rotating objects yourself. You can accomplish this with ... autoOrients property and set it to false. While you will still receive the ORIENTATION_CHANGE and ORIENTATION_CHANGING events when the actual device orientation changes, the stage will not update to try and match that orientation."

                   

                  This does not work in practice however (keeping in mind I have used various combinations of true and false autoOrients and preventDefault - nothing works as described, until setting autoOrients to true, but then the orientation changes, even when I use preventDefault as described in the docs!?):

                   

                  stage.scaleMode = StageScaleMode.NO_SCALE;

                  stage.align = StageAlign.TOP_LEFT;

                  stage.autoOrients = false;

                  main.appOrientation.text = 'Loading...';

                  // we can control which orientations we want to allow with the following code

                  stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, onOrientationChanging );

                  function onOrientationChanging( event:StageOrientationEvent ):void {

                      main.appOrientation.text = StageOrientation;  

                      // If the stage is about to move to an orientation we don't support, let's prevent it

                      // from changing to that stage orientation.

                      if(event.afterOrientation == StageOrientation.ROTATED_LEFT || event.afterOrientation == StageOrientation.ROTATED_RIGHT){

                          //main.appOrientation.text = 'Change';

                          event.preventDefault();

                      }

                  }

                  • 7. Re: StageOrientation without device auto-orientation
                    Katush Level 1

                    Has anybody else been able to rotate their app orientation manually without autoOrients? Or am I the only one that can't get it working?

                    • 8. Re: StageOrientation without device auto-orientation
                      Katush Level 1

                      After some additional testing, I can confirm that the AIR test works on my desktop as expected; the app orientation DOES NOT change, but the orientation value DOES change, when the desktop device test simulates Rotate Left and Rotate Right. It just doesn't work as documented, when actually tested on an actual ios device.

                      • 9. Re: StageOrientation without device auto-orientation
                        kglad Adobe Community Professional & MVP

                        so, it really doesn't work, at all then?

                         

                        were you able to test on more than one ios version?  which ios version(s)  failed to generate orientation changes when autoRotate was disabled?

                         

                        were you able to test on android?

                        • 10. Re: StageOrientation without device auto-orientation
                          Katush Level 1

                          I have tried this on two device (autoOrients true with event.preventDefault); iOS 7.1.1 iPad 3 and iOS 8.1 iPhone 5 ... neither works, though with differing results. I do not have any android devices to test on.

                          iOS 7.1.1 orientation value works (success) ... but so does the actual app rotation (fail).

                          iOS 8.1 orientation value does not work (fail) ... but the actual app does not rotate (success).

                          It seems like this has not been properly tested. A quick sample file would have helped confirm this, but I have logged the fault with Adobe Support and will update this post with my progress on that.

                          • 11. Re: StageOrientation without device auto-orientation
                            Katush Level 1

                            I have had no progress with Adobe support on this issue directly, but spurred by an Adobe post somewhere else, it is documented that the retraction of the preventDefault feature back in AIR 4 (or something) was made so that either no orientation is returned to the device at all, or native device orientation behaviour is faithfully honoured (seemingly default auto orientation behaviour).

                             

                            In short, Adobe Flash's auto orientation doesn't work quite as smoothly and effortlessly as xcode's. It is only because of this, that ORIENTATION_CHANGE should not be used, so that I can instead create my own rotation effect. This early in Adobe Flash mobile development however, I am not sure what the battery perfromance hit is in doing this, so am just looking at this as a learning. I have a rough working version so far and it is highly gratifying.

                            1 person found this helpful