完全可调整大小的应用程序 - Flex 4.5
我想使用 Flex 4.5 创建一个完全可调整大小的应用程序。我已经尝试过,但我的方法似乎很难维护,所以对我来说看起来不太好。这是我的方法:
- 关于 HTML,我实际上有一个第一页,它检测用户的显示器分辨率,然后重定向到 Flash 容器 HTML(JSP),该容器读取宽度和高度参数并将 Flash 呈现为
- 在我的应用程序中 传递的尺寸我使用 1280x720 作为参考尺寸,因此我创建了一个实用程序类:
package utils { 导入 mx.collections.ArrayCollection; 导入 mx.core.FlexGlobals; 导入 mx.resources.ResourceManager; 导入 mx.utils.ObjectProxy;
/**
*
* @author user
*
*/
public final class LayoutUtils
{
/**
*
*
*/
public function LayoutUtils()
{
throw new Error("Boooohhhhhhhhhh");
}
public static function relativeToHeight(percentageValue:Number):Number
{
return percentageValue * FlexGlobals.topLevelApplication.height / 100;
}
public static function relativeToWidth(percentageValue:Number):Number
{
return percentageValue * FlexGlobals.topLevelApplication.width / 100;
}
}
我
传递相对于高度或宽度的百分比值,然后返回该值。因此,我实际上将组件的高度/宽度绑定到例如 {LayoutUtils.relativeToWidth(50)}
,如果我的应用程序宽度为 1280,它将返回 640。但这意味着将宽度和/或高度设置为几乎每个组件,这还包括填充和锚点位置,这使得它变得一团糟。
您还有其他建议吗?我希望所有内容都能正确调整大小(包括字体)。我将提供的所有可用尺寸将保持相同的纵横比,例如 16:9,因为我看不到任何其他方法。
有什么建议吗?
I would like to create an totally re-sizable application using Flex 4.5. I experimented already but my approach seems to be hard to maintain so it does not look good to me. Here is my approach:
- Concerning the HTML I actually have a first page which detects the user's monitor resolution and then redirects to the flash container HTML(a JSP) which reads the width and height parameters and renders the flash to the size passed
- In my application I used the 1280x720 as the reference size so I have created a utility class:
package utils
{
import mx.collections.ArrayCollection;
import mx.core.FlexGlobals;
import mx.resources.ResourceManager;
import mx.utils.ObjectProxy;
/**
*
* @author user
*
*/
public final class LayoutUtils
{
/**
*
*
*/
public function LayoutUtils()
{
throw new Error("Boooohhhhhhhhhh");
}
public static function relativeToHeight(percentageValue:Number):Number
{
return percentageValue * FlexGlobals.topLevelApplication.height / 100;
}
public static function relativeToWidth(percentageValue:Number):Number
{
return percentageValue * FlexGlobals.topLevelApplication.width / 100;
}
}
}
I pass the percentage value relative to height or width and I get back just that. So I actually bind the height/width of components to e.g {LayoutUtils.relativeToWidth(50)}
which would return 640 if my applications width would be 1280. But this means setting width and/or height to almost every component and this includes also padding and anchor positions which makes it a mess.
Do you have any other suggestions? I want everything to be re sized correctly(including fonts). All the available sizes I am going to have available will keep the same aspect ratio which is going to be 16:9 for example because I can't see any other way of doing it.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想缩放任何内容,请在应用程序容器(精灵)上使用
scaleX
和scaleY
并设置If you want to scale anything, use
scaleX
andscaleY
on your application container (sprite) and set