performance - ="100%"和 left ="0"right ="0"哪个性能更好?

标签 performance apache-flex mxml

在最新的 Adob​​e Flex sdk 4.6 中,从性能角度来看,哪些方面更好?

<s:Group width="100%" height="100%"/>

<s:Group left="0" right="0" top="0" bottom="0"/>

谢谢。

最佳答案

BasicLayout.updateDisplayList()中我发现了这个(在每个子元素的循环中):

if (!isNaN(percentWidth))
            {
                var availableWidth:Number = unscaledWidth;
                if (!isNaN(left))
                    availableWidth -= left;
                if (!isNaN(right))
                     availableWidth -= right;

                childWidth = Math.round(availableWidth * Math.min(percentWidth * 0.01, 1));
                elementMaxWidth = Math.min(layoutElement.getMaxBoundsWidth(),
                    maxSizeToFitIn(unscaledWidth, hCenter, left, right, layoutElement.getLayoutBoundsX()));
            }
            else if (!isNaN(left) && !isNaN(right))
            {
                childWidth = unscaledWidth - right - left;
            }

高度也一样。

所以,看起来像:

  1. percenWidth 的优先级高于 topleft(如果两者都设置了)
  2. topleftpercenWidth更容易计算(对round进行单次减法、函数调用和条件)
  3. topleft 可以用作样式声明。

此外,大多数 Flex4 皮肤都是基于顶部左侧 - 我认为也是出于性能原因。

关于performance - ="100%"和 left ="0"right ="0"哪个性能更好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10896067/

相关文章:

c++ - 添加打印语句可将代码速度提高一个数量级

performance - Jmeter : How to increment a value inside the request

apache-flex - Flex 防止软键盘关闭

apache-flex - Flex 中的生产日志记录

apache-flex - 如何在 Flex 中直观地显示容器的 "break out"?

javascript - 如何隐藏包含许多 HTML 元素的页面上不可见 View 中的内容以提高性能?

javascript - 响应长键值对组件的性能影响

ios - 在 flex mobile 中,如何在 swf 文件中单击 url 时打开 puffin web 浏览器?

apache-flex - 在 DataGrid 中使用验证器 - Flex