• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

StageOrientationEvent.ORIENTATION_CHANGE not Dispatching

Participant ,
Dec 20, 2011 Dec 20, 2011

Copy link to clipboard

Copied

Hi!

why in my Mobile Application is not dispatching the StageOrientationEvent event?

What's wrong?

I set in my project "Automatically reorient".

This is my view:

<?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" title="HomeView" creationComplete="view1_creationCompleteHandler(event)">

    <fx:Script>

        <![CDATA[

            import mx.events.*;

            import mx.events.StateChangeEvent;

            import mx.states.AddChild;

           

            protected function view1_creationCompleteHandler(event:FlexEvent):void{

                addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, changeOrientationListener)

            }

            protected function changeOrientationListener(event:Event):void{

                trace(event)

            }

        ]]>

    </fx:Script>   

</s:View>

thanks

TOPICS
Development

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Dec 20, 2011 Dec 20, 2011

Solved:

<?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" title="HomeView" creationComplete="view1_creationCompleteHandler(event)">

    <fx:Script>

        <![CDATA[

            import mx.events.*;

           

            protected function view1_creationCompleteHandler(event:FlexEvent):void{

                addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage)

            }

           

           

            pri

...

Votes

Translate

Translate
Participant ,
Dec 20, 2011 Dec 20, 2011

Copy link to clipboard

Copied

Solved:

<?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" title="HomeView" creationComplete="view1_creationCompleteHandler(event)">

    <fx:Script>

        <![CDATA[

            import mx.events.*;

           

            protected function view1_creationCompleteHandler(event:FlexEvent):void{

                addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage)

            }

           

           

            private function _onAddedToStage(event:Event):void{

                if(stage.autoOrients)       

                    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, _onStage_OrientationChange);

            }

           

            private function _onStage_OrientationChange(event:StageOrientationEvent):void{

               

                switch(event.afterOrientation){

                   

                    case StageOrientation.DEFAULT:

                        trace('DEFAULT')

                        break;

                   

                    case StageOrientation.ROTATED_RIGHT:

                        trace('ROTATED_RIGHT')

                        break;

                   

                    case StageOrientation.ROTATED_LEFT:

                        trace('ROTATED_LEFT')

                        break;

                   

                    case StageOrientation.UPSIDE_DOWN:

                        trace('UPSIDE_DOWN')

                        break;

                   

                    case StageOrientation.UNKNOWN:

                        trace('UNKNOWN')

                        break;

                }

            }

        ]]>

    </fx:Script>   

</s:View>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 08, 2012 Feb 08, 2012

Copy link to clipboard

Copied

This code works for me, but not if i pushed a view first. And i put the code the the "pushedView" it doesnt work. What could solve the problem?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 28, 2012 Mar 28, 2012

Copy link to clipboard

Copied

Thank you very much

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 15, 2012 Jun 15, 2012

Copy link to clipboard

Copied

LATEST

this again works for my app in the Emulator, but on my device, it still updates late, changing according to the dimensions of the screen before the orientation change. How could this be??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines