Change View State Based On Screen Orientation?

I'd like my app to change layouts based on the current screen orientation.  I believe this is done through view states.  I have three questions...
1) How do I check the current orientation?
2) Is there an event listener that will tell me when the orientation changes?
3) How do I toggle between view states?
Thank in advance!
UPDATE: I figured out the answer to question 3...
currentState = 'yourStateName';
UPDATE II: I figured out the answer to question 1 as well.  I simply used the Capabilities object to determine the screens current width & height, then compare the two.  All of this is in a function that gets called when the app launches:
public function checkOrientation():void
     var screenWidth:Number = Capabilities.screenResolutionX;
     var screenHeight:Number = Capabilities.screenResolutionY;
     if (screenWidth > screenHeight) {currentState='yourStateName1';}
     else if (screenWidth < screenHeight) {currentState='yourStateName2';}
Now all I have to do is figure out how to call this function when there is an orientation change.  I tried the code below but get the included error:
stage.addEventListener(Event.RESIZE, checkOrientation); // ERROR: Access of undefined property stage
Why can't access the "stage" property???

Hi,
I work on platform using flash bulider 4, later i finsh the platform but i meeting one problem is resize project to work with diffrent size screen, but i can't solve the problem, i need platform work with diffrent Screen Orientation without problem could some help  please, this that what i done in code please help.
Thanks,
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:rtc="http://ns.adobe.com/rtc" width="100%" height="100%" backgroundColor="#51575D">
       <fx:Style source="Client.css"/>
         <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            import flash.events.FullScreenEvent;
            protected function txtUsername_enterHandler(event:FlexEvent):void
                // TODO Auto-generated method stub
                connectRoom.login();
                labelUsername.visible = false;
                txtUsername.visible = false;
            function fullScreenRedraw(event:FullScreenEvent):void
                if (event.fullScreen)
                    width  = Capabilities.screenResolutionX;
                    height = Capabilities.screenResolutionY;
                else
                    width = stage.stageWidth;
                    height = stage.stageHeight;
        ]]>
    </fx:Script>
       <fx:Declarations>
         <s:Move duration="500" id="moveEffect"/>
        <s:Resize duration="500" id="resizeEffect"/>
    </fx:Declarations>
              <mx:Image x="0" y="0" width="100%"  height="100%" scaleContent="false" autoLoad="true" source="greenbackground.png"/>
                                 <rtc:ConnectSessionContainer horizontalScrollPolicy="off" verticalScrollPolicy="off" id="connectRoom" autoLogin="false"
                                       roomURL="https://collaboration.adobelivecycle.com/account/yourroom"
                                       y="20" width="95%" height="90%" backgroundColor="#212D4B" contentBackgroundColor="#F6F6F0" borderAlpha="1.0" cornerRadius="30" contentBackgroundAlpha="1.0" backgroundAlpha="0.4" x="33" dropShadowVisible="true" borderVisible="true">
                    <rtc:authenticator>
                            <rtc:AdobeHSAuthenticator userName="{txtUsername.text}"/>
                 </rtc:authenticator>
                      <rtc:SimpleChat width="293" height="258" x="2" y="165" chromeColor="#384D91"/>
                       <rtc:WebcamSubscriber y="4" displayUserBars="true"  width="292" height="158" x="2"/>
                 <rtc:AudioSubscriber id="audioSub" width="0" height="0"/>
                                     <rtc:FileShare height="135" width="290" x="5" y="425" chromeColor="#284C79"/>
                    <rtc:ScreenShareSubscriber id="scrShare" width="81%" height="99%" y="4" x="299"/>
    </rtc:ConnectSessionContainer>
    <s:Label id="labelUsername" y="230" text="   Enter a username and press Enter:&#xd;" color="#B5C40D" fontWeight="bold" horizontalCenter="0"/>
    <s:TextInput y="250" width="229" textAlign="center" id="txtUsername" enter="txtUsername_enterHandler(event)" color="#090909"
horizontalCenter="0" height="27" fontWeight="bold" borderAlpha="0.99" contentBackgroundColor="#989A9C"/>
</s:Application>

Similar Messages

  • What is the best practice for changing view states?

    I have a component with two Pie Charts that display
    percentages at two specific dates (think start and end values).
    But, I have three views: Start Value only, End Value only, or show
    Both. I am using a ToggleButtonBar to control the display. What is
    the best practice for changing this kind of view state? Right now
    (since this code was inherited), the view states are changed in an
    ActionScript function which sets the visible and includeInLayout
    properties on each Pie Chart based on the selectedIndex of the
    ToggleButtonBar, but, this just doesn't seem like the best way to
    do this - not very dynamic. I'd like to be able to change the state
    based on the name of the selectedItem, in case the order of the
    ToggleButtons changes, and since I am storing the name of the
    selectedItem for future reference.
    Would using States be better? If so, what would be the best
    way to implement this?
    Thanks.

    I would stick with non-states, as I have always heard that
    states are more for smaller components that need to change under
    certain conditions, like a login screen that changes if the user
    needs to register.
    That said, if the UI of what you are dealing with is not
    overly complex, and if it will not become overly complex, maybe
    states is the way to go.
    Looking at your code, I don't think you'll save much in terms
    of lines of code.

  • Can we change the state based upon another field value?

    I want to change the state to Done when completed work is set to 0. I googled it and came to know about this:
    Handle it from the server side, monitoring the WorkItemChanged event. The downside is that it doesn't reflect immediately in the end-user screen. After editing a work item, the user would have to hit Refresh to see the new state.
    Will it be perfect in this way? Any other suggestions.
    Please provide best links to learn about creating server plugins and depoying.

    Hi divya,
    For your questions, you can refer to the link that Alexandr mentioned above to check the Pros and cons of custom controls for work item tracking.
    And for server side plugin, it has the ability to capture all the occurred events without exception. You can get more information about how to implement it by refering links below:
    https://socialtfs.codeplex.com/wikipage?title=How%20to%20create%20and%20debug%20a%20Team%20Foundation%20Server%20server-side%20plugin&referringTitle=Documentation
    http://vgaltes.com/index.php/2013/04/14/create-a-team-foundation-server-event-handler/
    http://geekswithblogs.net/jakob/archive/2010/10/27/devleoping-and-debugging-server-side-event-handlers-in-tfs-2010.aspx
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Change Region width based on screen's resolution

    Hi All,
    I have a requirement where I have to control a region width based on user's screen resolution:
    I tried the below example but it didn't work for me:
    Determining screen resolution using JavaScript or PL/SQL
    Thanks.

    Thanks Tyson. That worked the way you explained.
    But the user wants to see in different way now. for example : If a user has two monitors with different resolutions and if he moves it from one screen to another, the region should get adjusted according to that.
    Also, I am using a manual tabular form to create a report. I can control the width of the region by using your code but not able to control the text element (DEFINITION). I tried to wrap it but 'WRAP' didn't work for me either. please see the code below:
    select distinct '' change_display,
    apex_item.checkbox (20,
    id,
    null,
    Case when (instr(:P309_VA_STRATEGIC_GOAL, id ) >0)
    then id
    end )checkbox,
    ID ID_DISPLAY,
    apex_item.hidden (21, ID) || apex_item.text (22, DEFINITION ,166,1900,
    'style="background-color: #F9FAF5; border: 1px solid #F9FAF5;" readonly="readonly; " '
    )DEFINITION
    from Dar_asd.VA_STRATEGIC_GOAL
    order by ID
    Thanks.

  • Navigation based on screen orientation (landscape or portrait) in Flash CS6

    I'm creating an app that will have a different menu if the phone is held landscape, or portrait.
    I figure I have to tell flash to move to a new frame when the phone moves from landscape to portrait or vice versa, but I'm not sure the exact code to after creating the orientation event listener.

    your orientation listener should call a function that executes a gotoAndStop.
    the stage has an Stage.OrientationEvent.ORIENTATION_CHANGE event you can use:
    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE,changeF);
    function changeF(e:StageOrientationEvent):void{
    trace(e.afterOrientation.toString());

  • Air 2.6 Screen orientation

    I'm trying to get this Air 2.6 feature to work again.
    http://kb2.adobe.com/cps/891/cpsid_89107.html
    Changes in AIR 2.6
    Screen orientation changes in 2.6 namespace
    Based on the release doc, it says "The swf is required to be compiled with the flag "-target-player=11" to make use of supportedOrientations API."
    How do I "compile with the flag" ???
    I'm using Flash CS5 to publish .swf
    I got the adt cmd line working.
    My AS3 script:
    addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange);
    function onOrientationChange(event:StageOrientationEvent):void {
         trace("onOrientationChange:"+event.afterOrientation);
        ...and process result.
    Thanks,
    Alfred

    StageOrientationEvent.ORIENTATION_CHANGE and StageOrientationEvent.ORIENTATION_CHANGING are not part of the supportedOrientations API. If you want to prevent Portrait, you can do that like this:
    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging);
    private function orientationChanging(e:StageOrientationEvent) {
    if (e.afterOrientation == "default" || e.afterOrientation == "upsideDown") {
    e.preventDefault();
    That trick will work with AIR 2.0 as well as AIR 2.6, and without requiring player 11.

  • Selecting View States and TabNavigator Canvases

    Hello all Flex fans...
    I have two questions for somebody who has done this before.
    It will take a bit of explaining so bear with me.
    I have a datagrid called "selClaimant" as the starting point
    of my application. When I select something from the selClaimant
    datagrid I change view states to a view called "ClaimView". In the
    ClaimView state I have a TabNavigator control with several canvases
    called "Claimant" and "Claims" and several others.
    My first question is when I select something from the
    selClaimant datagrid how do I ensure that the Claimant canvas is
    displayed in the TabNavigator and not the Claims canvas???
    My second question is similar to the first but with a twist.
    First off the Claims canvas also has two view states (call them
    "ViewOne" and "ViewMany"). ViewOne has a datagrid control called
    selClaim that allows me to select a claim that has been filed by
    the claimant. ViewMany allows me to see all the details about the
    selected claim. When I select a claimant from the selClaimant
    datagrid I query the database to see how many claims that the
    selected claimant has filed. If there has only been one claim filed
    I want the starting state to be the ViewMany canvas when the user
    clicks on the Claims TabNavigator. If there is more than one claim
    in the database then I want the ViewOne to be displayed so I can
    select which claim I want the detail on.
    I store the number of claims in an array so I can use the
    array length to see if I have one or more claims but I am not sure
    how to logically force my view state and canvas state.
    Thanks in advance to the guru that helps me with this one!!!
    Have an Ordinary Day...
    KomputerMan ~|:-)

    Question one is answered... put this into the action script
    that handles the datagrid selected event.
    claimantTabNav.selectedIndex = 0;
    claimantTabNavigator is the ID of the tabnavigator whose
    canvas I want selected. 0 is the first tab in the navigator. Good
    thing I grew up on UNIX and can still remember how to count
    starting with a 0 instead of a 1. :)
    Have an Ordinary Day...
    KomputerMan ~|:-)

  • Programmatically change screen orientation and/or resolution using VBA?

    We don't have VB.NET available and I was wondering if it is possible to create VBA code that would change:
    1) screen orientation (and maybe resolution)
    2) on a specific monitor (in a multiple monitor setup; we have two) 
    The idea would be to put it into an Excel workbook and have the macro autorun then exit.
    I see examples for C#.Net but can't find any for VBA. Maybe it's not possible. Your comments are appreciated. Thanks.
    Note: ANY MS Office application can be used as long as it can be used via a shortcut on the desktop and run
    automatically. "One click and done" is the idea.

    Hi Dougmeister,
    I agree with Cindy that the VBA doesn't have function to achieve the goal. Also there is no function in Excel object for this requirement.
    The way we can achieve the goal is that using Windows API as Cindy motioned. And here is an helpful article talking about this topic:
    Office Talk: Working with VBA in the 32-bit and 64-bit Versions of Office 2010
    And about Windows API issue, I would suggest that you get more effective response from
    General Windows Desktop Development Issues forum.
    Hope it is helpful.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Monogame, how to stop screen orientation from changing

    Hi,
    I am having a really annoying problem with mono game for windows 8 phone.
    The landscape keeps changing its orientation even though I have it set to landscapeleft.
    Someone please put me put of my misery.
    Xaml
    SupportedOrientations="Landscape"  Orientation="LandscapeLeft"
    Game cs
     graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;

    Hi Smilesprower,
    How about the setting on your manifest? You have to check the supported rotations.
    Besides,
    Supporting screen orientation is also a helpful documentation if you are using DirectX part for Mono games
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Change base view state from a custom component

    I'm pretty new to flex and I'm having a small issue in change the view state from a component.
    My Application have 2 custom components called userlogin and main menu. In the main application page I have userlogin component in one state and the main menu component in another. I'm trying to change the state if the login in successful from user login to main menu. I have the following function written inside the login component.
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    This code worked when I had all the controls in the main page. But then I created components and included them in to components and now when the login is success, its giving the following error.
    ArgumentError: Undefined state 'MainMenu'.
        at mx.core::UIComponent/getState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UI Component.as:9908]
        at mx.core::UIComponent/findCommonBaseState()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9928]
        at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:9750]
        at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ core\UIComponent.as:9701]
        at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087 ]
        at components::UserLoginForm/__btnSubmit_click()[C:\Projects\WarrantyAutomation\src\componen ts\UserLoginForm.mxml:60]
    I'm sure this has something to do with accessing the states from a custom component, but I do not know how to change the state to the main menu. Please help me with this. Any help is greatly appriciated.

    Hi dasun1981,
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    If I am right the above function is in your userlogin component and the two components "userlogincomponent" and "maincomponent" are in main application file and the states were also defined in main application file.
    But in the function above the currentState refers to the state of the userlogin component and not the main application ...but the states are defined in main application file...that's the reason why the exception was thrown...
    Instead you replace the line in the above function with the below line:
    Application.application.currentState = "MainMenu";
    Please mark it as answer if it helped you.
    Thanks,
    Bhasker Chari

  • Programmatically change screen orientation and/or resolution?

    We don't have VB.NET available and I was wondering if it is possible to create VBA code that would change:
    1) screen orientation (and maybe resolution)
    2) on a specific monitor (in a multiple monitor setup; we have two) 
    The idea would be to put it into an Excel workbook and have the macro autorun then exit.
    I see examples for C#.Net but can't find any for VBA. Maybe it's not possible. Your comments are appreciated. Thanks.
    Edit: ANY MS Office application can be used as long as it can be used via a shortcut on the desktop and run automatically. "One click and done" is the idea.

    Hello Doug,
    I believe you can use Windows API functions to get the job done.
    Anyway, the current forum is for Office Apps. I'd recommend asking VBA questions on the
    General Office Development  forum instead.

  • Cat changed screen orientation from vertical to horizontal

    What key combination will reorient my display from horizontal back to vertical? Do you know someone who is looking for a cat. Ours is now looking for a new home.

    Here you go...
    http://www.dq.winsila.com/windows/windows-xp-tips/how-to-change-the-screen-orientation-in-windows-xp...
    Paul

  • The screen orientation won't change even though it shows orientation as unlocked

    the screen orientation won't change even though it shows orientation as unlocked on the bottom of the screen and when I release the side button.  Any ideas?

    If rotation lock is not set (i.e. there is no lock symbol next to the battery indicator at the top of the screen, http://support.apple.com/kb/HT4085), then try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • How can I change screen orientation on my iPad air 2?

    How can I change the scrEen orientation on my new iPad Air 2? I do not see a lock device on the side like my old iPad has.

    Tap the padlock icon in Control Center.

  • Locale Input changes on Mac OS X Lion when changing the view state

    On Mac OS X Lion, the following code results of changing the locale input when changing the view state. If you set the input locale to Pynin, then run the application, then click on "go to the test 2", the input locale changes back to english. This is obviously not the correct behavior (the input locale should stay the same as defined on the computer).
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx">   
        <fx:Script>
            <![CDATA[
                protected function gototest2(event:MouseEvent):void
                    this.currentState = "test2";
                protected function gototest(event:MouseEvent):void
                    this.currentState = "test";
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="test" />
            <s:State name="test2" />
        </s:states>
        <s:Button label="go to test" includeIn="test2" click="gototest(event)" />
        <s:Button label="go to test2" includeIn="test" click="gototest2(event)" />
        <s:TextInput includeIn="test2" />
    </s:WindowedApplication>

    Could you please open a new bug report on this over at bugbase.adobe.com?  Please post back with the URL so that others affected can add their comments and votes.

Maybe you are looking for