Stan Reshetnyk
Stan Reshetnyk

Reputation: 2036

What is better for perfomance width="100%" or left="0" right="0"?

In latest Adobe Flex sdk 4.6, what is better from performance view?

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

or

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

Thank you.

Upvotes: 2

Views: 467

Answers (1)

radistao
radistao

Reputation: 15524

In BasicLayout.updateDisplayList() i found this (in loop for every child element):

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;
            }

And same for height.

So, looks like:

  1. percenWidth has higher priority than top and left (if both are set)
  2. top and left calculated easier than percenWidth (single subtraction against round, functions call and conditions)
  3. top and left may be used as styles declarations.

Also, most of Flex4 skins are based top and left - i think for performance reason too.

Upvotes: 5

Related Questions