Flex 4.5 - 如何检测屏幕尺寸以使图像在移动设备上居中?

时间:2011-11-23 05:32:39

标签: flex actionscript flex4 mxml flex4.5

stage.stageWidth上尝试stageHeightapplicationComplete,但由于某种原因,返回的实际数字似乎不准确 - 图片始终显示为偏心(stageWidth / 2 - imageWidth / 2)。

如何确定移动设备的实际屏幕尺寸,使对象居中?

1 个答案:

答案 0 :(得分:4)

你试过了吗?

    popUp.width = FlexGlobals.topLevelApplication.width - 40; //popup - leave side edges
    popUp.height = FlexGlobals.topLevelApplication.height - 40; //popup - leave top + bottom edges

    popUp.x = FlexGlobals.topLevelApplication.width/2 - popUp.width/2; //popup x coord
    popUp.y = FlexGlobals.topLevelApplication.height/2 - popUp.height/2; //popup y coord