闪存Pro作为3.0航为iOS,这次活动不工作闪存、工作、Pro、iOS

2023-09-08 13:58:27 作者:保质期少女

我正在开发一个默认方向iOS的设置,设置为肖像的Flash航空的应用程序;而自动定向关闭。

I'm developing an app with a default orientation set to Portrait in Flash Air for iOS settings; and the auto orientation is off.

加入一定的MovieClip我希望它来检测,如果方向变化,然后改变其位置的横向或纵向显示之后不过。

However after adding a certain movieClip I want it to detect if the orientation changes and then change its position for a landscape or portrait display.

问题是,StageOrientationEvent.ORIENTATION_CHANGE不会被分派,如果我禁用自动方向。而且,即使它被启用,听者只会派遣时的方向变化倒置或默认(未景观)

The problem is that StageOrientationEvent.ORIENTATION_CHANGE wont be dispatched if I disable the auto orientation. And even if it is enabled, the listener will only dispatch when the orientation changes to upside down or default (not landscapes)

package  
{  

    import flash.display.MovieClip;  
    import flash.events.MouseEvent;  
    import flash.display.Stage;  
    import flash.events.StageOrientationEvent;  
    import flash.display.StageOrientation;  
    import flash.events.Event;  
    public class NoteBook extends MovieClip  
    {  
        public var type: String = new String();  
        public var deviceHeight: Number = new Number();  
        private var nbp: NoteBookPic;  

        public function NoteBook(DeviceHeight: Number = 720)  
        {  
            nbp = new NoteBookPic();  
            this.addChild(nbp);  

            nbp.deviderPic.visible = false;  
            this.deviceHeight = DeviceHeight;  

            this.x = 0;  
            this.y = deviceHeight / 2;  
            this.scaleY = (deviceHeight / 720) * .65;  
            this.scaleX = this.scaleY;  

            this.addEventListener(MouseEvent.CLICK, clicked);  
            this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);  
        }  
        public function exit()  
        {  
            this.removeEventListener(MouseEvent.CLICK, clicked);  
            this.stage.removeEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orient);  
            this.parent.removeChild(this);  
        }  
        private function clicked(e: MouseEvent)  
        {  

        }  
        private function addedToStage(e: Event)  
        {  
            this.removeEventListener(Event.ADDED_TO_STAGE, addedToStage);  
            this.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orient);  
        }  
        private function orient(e: StageOrientationEvent)  
        {  
            trace(e.beforeOrientation, e.afterOrientation)  
        }  
    }  

}  

更新:

我刚刚读ActionScript®3.0参考用于Adobe®Flash®Platform的的是StageOrientationEvents只派出了设备旋转时autoOrientation是真实的;但正如我所说,即使启用了上面,听者只会派遣时的方向变化倒置或默认(未景观)。这在我的情况是一个问题,因为我的应用程序必须是除了当我的舞台是非常影片剪辑的肖像应用程序。而当它在舞台上,我希望它作出反应的任何方向改变,两个人像和两个风景。

I just read in ActionScript® 3.0 Reference for the Adobe® Flash® Platform that StageOrientationEvents are only dispatched for device rotation when autoOrientation is true; but as I mentioned above even if it is enabled, the listener will only dispatch when the orientation changes to upside down or default (not landscapes). Which in my case is a problem as my app must be a portrait app except for that very MovieClip when on my stage. And when it is on stage I want it to react to any orientation changes, two portraits and two landscapes.

推荐答案

您正在使用StageOrientationEvent.ORIENTATION_CHANGE这是正确的。我没经过你的code,因为我没有看到关键的东西。下面的例子关键code。

You're using StageOrientationEvent.ORIENTATION_CHANGE which is correct. I didn't go through your code because I don't see key stuff. Below is example key code.

一个时髦的事情是,Capabilities.screenResolutionX和Capabilities.screenResolutionY会给你的屏幕尺寸,但它们不与设备旋转变化。所以,你必须跟踪屏幕方向,并设置宽度和高度自己。

One funky thing is that Capabilities.screenResolutionX and Capabilities.screenResolutionY will give you the screen dimensions but they do not change with device rotation. So you have to keep track of the screen orientation and set width and height yourself.

var bStagePortrait: Boolean;

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged);

if (stage.orientation == StageOrientation.DEFAULT || stage.orientation == StageOrientation.UPSIDE_DOWN) {
    bStagePortrait = true;
} else if (stage.orientation == StageOrientation.ROTATED_LEFT || stage.orientation == StageOrientation.ROTATED_RIGHT) {
    bStagePortrait = false;
}

//  set width and height based on current rotation (Capabilities.screenResolutionX and Y do not change with device rotation)
function fSetScreenDimensions(): void {
    if (bStagePortrait) {
        iWidth = Capabilities.screenResolutionX;
        iHeight = Capabilities.screenResolutionY;
    } else {
        iWidth = Capabilities.screenResolutionY;
        iHeight = Capabilities.screenResolutionX;
    }
}

private function orientationChanged(e: StageOrientationEvent): void {
switch (e.afterOrientation) {
    case StageOrientation.DEFAULT:
        bStagePortrait = true;
        break;
    case StageOrientation.ROTATED_RIGHT:
        bStagePortrait = false;
        break;
    case StageOrientation.ROTATED_LEFT:
        bStagePortrait = false;
        break;
    case StageOrientation.UPSIDE_DOWN:
        bStagePortrait = true;
        break;
    }
}