StageOrientationEvent 未在 ActionScript 3 中调度
我有来自 adobe 论坛的这段代码,它可以在移动应用程序的第一个屏幕上运行。但如果我将此代码放在新视图中(在我推送的视图中),它就不起作用 有人知道这个问题的解决办法吗?
<?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>
i have this code from the adobe forum, which works on the first screen of a mobile application. But it doesnt work if i put this code in a new view ( in a view which i have pushed )
Does anybody know the solution to this problem?
<?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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
try this: