Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7067715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:14:09+00:00 2026-05-28T05:14:09+00:00

Is anyone able to actually make it work properly in Flex SDK 4.6? Here’s

  • 0

Is anyone able to actually make it work properly in Flex SDK 4.6?

Here’s a short snippet :

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        addedToStage="onAddedToStage(event)"
        title="Title">
    <fx:Script>
        <![CDATA[  
            private function onAddedToStage(event:Event):void { 
                if (stage.autoOrients) {
                    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging, false, 0, true);
                }
            }

            private function orientationChanging(event:StageOrientationEvent):void {
                if (event.afterOrientation == StageOrientation.DEFAULT || event.afterOrientation == StageOrientation.UPSIDE_DOWN) {
                    event.preventDefault(); 
                }     
            } 
        ]]>
    </fx:Script>
</s:View>

What I’m trying to achieve is to support Landscape mode in both orientations, so if user turns the device 180 degress, the screen should also rotate. But there should be no action at all, when user rotates the device to one of portrait orientations. Instead, I’m seeing width changes to navigator action bar and sometimes content in portrait orientations, so apparently preventing the event is not enough. I’m using the “official” way Adobe suggests, but the problem is that it’s not working very well. Granted, the stage does not change, but it seems that there’s something firing in navigator anyway, since you can see the action bar width changing.

I had some success with explicitly setting layoutbounds to fixed width in handler method – this prevents changing the actionbar width, but it’s only a temporary solution – if the view is a subject to a transition, or some other redraw – it will again render with bad sizes. As if there was something below that was telling it that it’s in portrait mode, even though I’m trying to prevent it.

Before you detonate with some silly ideas like “autoOrient = false”, don’t. It’s clearly not a solution for this problem. Obviously it’s a bug with Flex SDK – did anyone find a way to fix it or a stable workaround?

EDIT: apparently others bumped into similar issue:
– http://forums.adobe.com/message/3969531 (the main topic is about something else, but read magic robots’s comment)
– http://forums.adobe.com/message/4130972

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:14:09+00:00Added an answer on May 28, 2026 at 5:14 am

    I’m not sure if this is the right one, did I do something wrong in the end, but after a lot of struggle, I’ve found this one to be stable solution:

    private function onAddedToStage(event:Event):void { 
        if (stage.autoOrients) {
            stage.removeEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging);
            stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging, false, 100, true);
        }
    }      
    
    private function orientationChanging(event:StageOrientationEvent):void {
        event.stopImmediatePropagation();
        if (event.afterOrientation == StageOrientation.DEFAULT || event.afterOrientation == StageOrientation.UPSIDE_DOWN) {
            event.preventDefault(); 
        }   
    }  
    

    First thing to note is that addedToStage fires few times (2-3) in mobile application. I don’t know why, there’s no addChild in my code, obviously. Maybe the AIR runtime does something else. So, to avoid adding unnecessary amount of handlers, the common technique is to remove handler first – it won’t do anything, if such handler is not yet registered, but if there is, it will remove it, which will maintain the handler count on 1.

    Second thing is the priority of the event – it won’t work on 0, it has to be set on something big, to launch before stuff in AIR runtime.

    Last thing – event.stopImmediatePropagation() – now, that we’re the first to handle the event, we cant prevent this event to be sent further up in this particular scenario.

    This together makes the orientation preventing working perfectly – for me the landscape and the reversed landscape (rotated_left, rotated_right) were working and transitioning, while portrait modes did not affect the view at all.

    Now, there’s danger here – you might want to remove the listener upon leaving the view (on transition animation end, view deactivate or something), because stopImmediatePropagation will prevent the event to be handled in other parts of your application.

    I hope Adobe (or Apache now, actually) will take a closer look at this problem and trace my solution.

    EDIT

    There remaisn a last issue with this solution, which is if application starts while device is in DEFAULT or UPSIDE_DOWN orientation, in this case application will be in portrait mode.

    To fix this, a solution is to change Aspect Ratio within addedToStage handler:

       if(Stage.supportsOrientationChange) {
             stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

anyone able to tell me how often a materialized view is set to refresh
Has anyone been able to get an NHibernate-based project up and running on a
Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default
Has anyone been able to get a variable record length text file (CSV) into
Has anyone been able to successfully unit test methods that are, by necessity, coupled
Has anyone been able to create Container-Specific Master Pages for Safari or Chrome? I
Has anyone been able to succesfully use the IE CSS hack #IEroot? I stumbled
Has anyone been able to implement the JQuery grid plugin, jqGrid? I'm trying to
Has anyone been able to customize jQGrid? While I'd like something easy I can
Would anyone be able to tell me how to pull the server name out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.