如何在运行时确定和设置屏幕尺寸使用动作脚本? [英] How to Determine and Set Screen Size at run time using action script?

查看:147
本文介绍了如何在运行时确定和设置屏幕尺寸使用动作脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,所以我开发使用动作脚本(土坯空单),因为我瑞士法郎的应用程序的屏幕尺寸为appox 840X480一个Android应用程序......我能察觉的Andr​​oid设备的屏幕大小在运行时运行的应用程序和设置相应的屏幕尺寸?如果是的话如何? P.S - 我还是菜鸟的动作脚本 谢谢

Hey so i am developing an android application using action script(the adobe air one) since the screen size of my .swf application is appox 840X480... Can i detect the screen size of the android device running application at runtime and set the screen size accordingly?? if so How?? P.S - I'm still rookie at Action-script Thank You

推荐答案

基本上,使您的应用程序的液体(或响应)。请按照下列步骤:

Basically, to make your app liquid (or responsive). Follow the following steps:

  1. 设置舞台对齐和缩放模式:

  1. Set the stage align and scale modes:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align     = StageAlign.TOP_LEFT;

  • 监听在舞台上调整大小事件:

  • Listen for resize events on the stage:

    stage.addEventListener(Event.RESIZE, stageResizeHandler);
    
    function stageResizeHandler(e:Event):void {
        stage.stageWidth; //how big the width is
        stage.stageHeight; //how big the height is.
    
        //so if you had a box, and you wanted it centered on the screen:
        box.x = (stage.stageWidth - box.width) * .5;
        box.y = (stage.stageHeight - box.height) * .5;
    
        //draw a background
        graphics.clear();
        graphics.beginFill(0xFF0000);
        graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight);
        graphics.endFill();
    }
    

  • 如果,你只是想知道显示器的物理尺寸,你可以在能力做到这一点类:

    If, you just want to know the physical size of the display, you can do so in the Capabilities class:

    Capabilities.screenResolutionX;
    Capabilities.screenResolutionY;
    

    stage.fullScreenWidth;
    stage.fullScreenHeight;
    

    这通常不包括任何虽然工具栏/通知栏。

    This usually doesn't include any tool bars /notification bars though.

    如果你只是想你的内容比例,然后设置缩放模式,以任何你想:

    If you just want your content scaled, then set the scale mode to whatever you'd like:

    stage.scaleMode = StageScaleMode.NO_BORDER; 
    //this will zoom in your app until it fills the whole screen, though it may crop it a bit if needed.
    

    要看到其他缩放模式,看<一href="http://stackoverflow.com/questions/27776458/how-to-make-flash-animation-responsive/27786709#27786709">here

    To see other scaling modes, look here

    这篇关于如何在运行时确定和设置屏幕尺寸使用动作脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆