4 Replies Latest reply on Mar 4, 2014 7:30 AM by lizardman2

    Flex Hero - how to lock screen orientation

    nirnirnir Level 1

      I'd like to keep the app screen locked on vertical mode in a couple of my application views, is there a way to do that?



        • 1. Re: Flex Hero - how to lock screen orientation
          mushmut Level 1




          I looking for the same! In my app i have a "media view" that display photo and video. This view is inevitably displayed as landscape.


          I've tried to create a custom layout that extends the layoutBase, but it seems that the layout doesn't affect tneh action bar.


          But i found a (not elegant but functional) solution.


          Create an action script class that extends LayoutBase.


          Override the updateDisplay method to something like this


               override public function updateDisplayList(width:Number, height:Number):void {
                         //reverse value 
                         var layoutTarget:GroupBase = target; 
                         var count:int = layoutTarget.numElements; 
                         for (var i:int = 0; i < count; i++) { 
                              var item:ILayoutElement = useVirtualLayout ? layoutTarget.getVirtualElementAt(i) : layoutTarget.getElementAt(i); 
                              //store x and y value of the item to repositionning  it later
                              var itemX:Number = target.getChildAt(i).x
                              var itemY:Number = target.getChildAt(i).y
                              // rotate the item trought a matrix     
                              var m:Matrix = new Matrix();
                              // reset the position of the item
                              // repositionning the item 


          In the view, set the actionBarVisible property to false and ctreate you own action bar.


          <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:dogLayout = "be.standard.core.layout.*"
               <s:layout >
          <!-- implementation of the custom layout -->
               <s:ActionBar width="800" height="60" x="60" >


          I hope Adobe's engineers think forcing orientation it's usefull :-)

          • 2. Re: Flex Hero - how to lock screen orientation
            nirnirnir Level 1

            Thanks! I'll give it a try asap

            • 3. Re: Flex Hero - how to lock screen orientation
              mushmut Level 1

              Hi ,


              I've wasted my time to look on this direction....


              You can just use stage.setAspectRatio(StageAspectRatio.PORTRAIT or StageAspectRatio.LANDSCAPE)....


              You can alos create a state for your view, and listening the StageOrientationEvent.ORIENTATION_CHANGE to modify the element's view disposition.http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/StageOrien tationEvent.html#ORIENTATION_CHANGE


              I think it's really easier . Probably you too.

              • 4. Re: Flex Hero - how to lock screen orientation
                lizardman2 Level 1

                I do apologize if you url is an obv. Total remedy to what I am asking.. Does your code provided work in Flash pro as3??