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
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
...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>
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?
Copy link to clipboard
Copied
Thank you very much
Copy link to clipboard
Copied
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??