import flash.display.StageOrientation;
import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
aotuOrien();
//------------------------------------------------------------------------------------自动旋转
function aotuOrien():void{
if (Accelerometer.isSupported){//判断是否支持屏幕方向
var accl:Accelerometer;
var orienTotal:int=0;
accl = new Accelerometer();
accl.setRequestedUpdateInterval(1000);//每1秒更新一次
accl.addEventListener(AccelerometerEvent.UPDATE,function(e:AccelerometerEvent):void{
//自动旋转
if(e.accelerationY<-0.2){
orienTotal++;
if(orienTotal>1){
orienTotal=0;
switch (stage.orientation){
case "rotatedLeft":
stage.setOrientation(StageOrientation.ROTATED_RIGHT);
break;
case "rotatedRight":
stage.setOrientation(StageOrientation.ROTATED_LEFT);
break;
}
}
}
});
}else{
//trace("您的系统不支持屏幕方向");
}
}
//------------------------------------------------------------------------------------自动旋转结束
Flash AS3.0开发Android apk如何禁止自动翻转
最新推荐文章于 2021-02-06 12:49:21 发布