0

我对 Actionscript 完全陌生。我到处搜索屏幕方向代码,但找不到合适的。我正在尝试制作一个具有多个页面(框架)的书籍应用程序,该应用程序具有纵向和横向模式。

我找到了 Adam Khoury 编写的代码,但它只适用于一帧。有没有办法将此代码用于具有不同影片剪辑的多个帧(页面)?这是他使用此代码的视频:goo.gl/T24ku

// AS3.0 Android App View Modes Script For App View Orientation
// Written by Adam Khoury
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
// Create stage instance and manipulate 2 of its properties
var appStage:Stage = myApp.stage;
appStage.scaleMode = StageScaleMode.NO_SCALE;
appStage.align = StageAlign.TOP_LEFT;
// Function that executes each time a phone or device is rotated
function orientateMyApp(event:Event):void {
    var device_width:int = appStage.stageWidth;
    var device_height:int = appStage.stageHeight;
    // Condition that allows toggling between view modes
    if(device_width > device_height){
        myApp.gotoAndStop("wide_view");
    } else {
        myApp.gotoAndStop("tall_view");
    }
}
// Add an event listener for the resize event of the stage instance
appStage.addEventListener(Event.RESIZE, orientateMyApp);
4

1 回答 1

0

与其在每个布局的时间轴上使用帧,不如将每个布局创建为自己的影片剪辑,然后将它们都放在一个帧上。使用可见属性显示/隐藏它们。在翻页时,同时推进两种布局模式,或存储 currentPage 以设置旋转后的布局。

if(device_width > device_height){
    //landscape mode
    landscapeView_mc.visible = true;
    portraitView_mc.visible = false;
} else {
    //portrait mode
    landscapeView_mc.visible = false;
    portraitView_mc.visible = true;
}
于 2012-07-14T00:48:26.360 回答