【问题标题】:What is the right way to scale a Flex application up to fullscreen?将 Flex 应用程序扩展到全屏的正确方法是什么?
【发布时间】:2011-07-05 13:20:06
【问题描述】:

全屏模式,我已经在这个 Flex 应用程序中苦苦挣扎了一段时间,但我在谷歌搜索结果中遇到了不足,以结束我的困境。我通过Application.application.stage.displayState = StageDisplayState.FULL_SCREEN; 进入全屏模式没有问题,但其余内容仅以原始大小位于左上角。

好吧,我说,我会做一个 stage.scaleMode = StageScaleMode.SHOW_ALL 并让 it 弄清楚如何解决这个问题。看起来确实如此。除了当您将鼠标悬停在各个复选框和按钮以及各种组件上时,它们都会稍微烦躁。当它们调整大小时,只需稍微向上或向下跳跃......鼠标悬停。好吧,这令人沮丧,但可以忍受。我总是可以为所有这些显式调用invalidateSize()

但对于组合框。底部的菜单离开屏幕的底部,当我退出全屏模式时,它们的下拉菜单会中断一半。我不知道如何解决那个。有人能走进来,让我摆脱痛苦吗?

将 Flex 应用程序扩展到全屏的正确方法是什么?

var button:Button = button_fullscreen;
try {
    if(stage.displayState == StageDisplayState.FULL_SCREEN) {
        Application.application.stage.displayState = StageDisplayState.NORMAL;
        button.label = "View Fullscreen Mode";
        stage.scaleMode = StageScaleMode.NO_SCALE;
    } else {
        Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
        button.label = "Exit Fullscreen Mode";
        stage.scaleMode = StageScaleMode.SHOW_ALL;
    }
    invalidateSizes(); // Calls invalidateSize() explicitly on several components.
} catch(error:SecurityError) {
    Alert.show("The security settings of your computer prevent this from being displayed in fullscreen.","Error: "+error.name+" #"+error.errorID);
} catch(error:Error) {
    Alert.show(error.message,error.name+" #"+error.errorID);
}

【问题讨论】:

    标签: apache-flex flash actionscript-3 fullscreen


    【解决方案1】:

    flex 有时会出错 :)

    尝试以下方法

    stage.align = StageAlign.TOP_LEFT;
    

    然后在调整大小或添加到舞台时手动设置缩放比例

    private function updateScaling():void
    {
       if(stage.stageWidth != width || stage.stageHeight != height)
       {
           var scaling:Number = 1;
           if(width>height)
           {
              scaling = stage.stageWidth / width;
           }
           else
           {
             scaling = stage.stageHeight / height;
           }
    
           scaleX = scaleY = scaling;
       }
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-14
      • 2020-08-18
      • 1970-01-01
      • 2018-05-07
      • 1970-01-01
      • 2020-02-13
      • 1970-01-01
      • 2012-03-01
      相关资源
      最近更新 更多