开发者

Flex: Why doesn't mx.core.Container always use the 'contentPane'?

Why is it that the mx.core.Container uses its contentPane sometimes, but doesn't at other times?

Or, in other words, how come the children of Container are only put into the con开发者_开发知识库tentPane if some complex logic decides that they should be put there? Why not simply always put all children in the contentPane?


If memory serves, addingChild() (which is probably an inherited method) in the sdk will be your answer. It has to do with styles and since I'm not the person to talk to about styles, I'm turning this answer into a community wiki, can't say I've ever done this...


Content pane is a simple display object that the container uses internally to host children but only when scrolling enabled. So this is why the children are 'sometimes' being placed inside the content pane. :)

This content pane is then being moved and this is how the container is being scrolled.

When switching 'scrollContent' ON and OFF, Flex moves the children from the container itself to the content pane and vice versa. Before the first move to the content pane it creates the pane.

What's also important is that this process is being transparent to the user, i.e. when adding/removing children, the container takes care of where to put them (to the container itself or the content pane). Also note that the layout mechanism operates on the children the same way in both cases (either with or without the content pane).

And now the answer to the question "Why not simply always put all children in the contentPane?".

Performance! We always tend to minimize the number of components in the application, so why use the content pane with each and every container while only the small number of containers has scrollContent set to true? The majority of containers in the average Flex app is just grouping its children in the horizontal or vertical fashion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜