对于移动Flex/Flash Builder,使用systemManager.screen.*
还是Stage.*
来检测屏幕尺寸会更好 - 为什么?Flex 4.6 - 检测手机屏幕尺寸 - systemManager.screen.width vs Stage.width
1
A
回答
2
在构建应用程序时,我认为知道我必须使用的空间比知道实际屏幕尺寸更重要。
要获取此信息,我将绑定到Flex框架并使用传递给updateDisplayList()方法的unscaledWidth和unscaledHeight属性。
问题是,为什么你需要检测屏幕尺寸。如果您只是需要使用它们来确定组件的孩子的大小和位置,那么我相信我上面描述的解决方案是最好的。如果您因其他原因需要此信息,请解释。
这是一个方式,大小和标签位置的里面的updateDisplayList它的容器:
protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledwidth, unscaledHeight);
// first position it
// you could also use this.myLabel.move(x,y) method to position the element
this.myLabel.x = 0;
this.myLabel.y = 0;
// then size it
// sizing to 100% height/width of container
this.myLabel.height = unscaledHeight;
this.myLabel.width = unscaledWidth;
// or you could also use setActualSize; which is slightly different than setting height and width
// becaues using setActualSize won't set the explicitHeight/explicitWidth, therefore measure will still
// execute
this.myLabel.setActualSize(unscaledWidth, unscaledHeight)
// or you could set the label to it's measured height and measured width
this.myLabel.height = this.myLabel.getExplicitOrMeasuredHeight();
this.myLabel.width = this.myLabel.getExplicitOrMeasuredWidth();
}
5
在大多数情况下,它是使用更可靠FlexGlobals.topLevelApplication.width
和FlexGlobals.topLevelApplication.height
。
相关问题
- 1. 用户手机屏幕尺寸
- 2. 屏幕尺寸检测后的Coldfusion
- 3. 屏幕尺寸变化的检测点
- 4. 检测物理屏幕尺寸
- 5. 有没有办法在MVC3中检索手机屏幕尺寸
- 6. 屏幕尺寸
- 7. 屏幕尺寸
- 8. 屏幕尺寸
- 9. 如何检测手机网页浏览器及其屏幕尺寸
- 10. XLARGE VS sw720dp屏幕尺寸的混乱
- 11. 每个屏幕尺寸手动
- 12. 与屏幕尺寸
- 13. Android屏幕尺寸
- 14. CSS屏幕尺寸
- 15. Monodroid屏幕尺寸
- 16. 屏幕尺寸5
- 17. Android屏幕尺寸
- 18. 屏幕尺寸到图像尺寸
- 19. 如何只检测CSS手机屏幕
- 20. 安卓相机的屏幕尺寸
- 21. Javascript自动屏幕尺寸测试
- 22. 我应该如何为小屏幕和大屏幕手机定义尺寸?
- 23. Android:相机的尺寸与屏幕尺寸不匹配
- 24. 尺寸为Windows 8手机闪屏
- 25. CSS片与手机尺寸
- 26. 如何检查初始屏幕尺寸
- 27. 如何使网站响应您的Android手机屏幕尺寸?
- 28. 管理不同的手机屏幕尺寸 - Haxe,OpenFL
- 29. 如何让网站适应手机和iPad屏幕的尺寸?
- 30. CSS不适用于小屏幕尺寸手机
我还不清楚'updateDisplayList()'如何定位组件的子元素。对于多行文本(默认)'标签',必须设置'width'。在线上的各种教程后,我从舞台/屏幕宽度--2 *边距(假设它跨越屏幕的可读宽度)设置此宽度。 updateDisplayList如何在那里工作? – ina
我更新了我的答案,提供了关于如何在updateDisplayList中设置组件大小的示例代码。 – JeffryHouser
我想我还没有理解的是你如何在运行时调整容器大小?看起来这将是不同的屏幕尺寸。 – ina