Herms
Herms

Reputation: 38868

Flex Layout overview - any way to get a component's preferred size?

Is there a good place that has an overview of how Flex layout stuff is managed?

I'm trying to create some user-resizeable "windows" in Flex, but I'm having some trouble getting the layout calculations for the contents correct.

Right now I'm just trying to get a good understanding of how Flex calculates its layouts, but I haven't found any good overview documentation.

For instance, looking just at the width value there are the following:

minWidth
maxWidth
width

explicitMinWidth
explicitMaxWidth
explicitWidth

measuredMinWidth
measuredMaxWidth
measuredWidth

and the same set for height.

What's the meaning of each of these? How is each used? Is there any way using those to calculate some preferred size of a component (like getPreferredSize() in java)?

Answers to that specific width/height question would be very helpful, but if anyone knows of some good documentation that goes over Flex's layout stuff in general that would be great.

Upvotes: 3

Views: 560

Answers (3)

Pieter Kuijpers
Pieter Kuijpers

Reputation: 7317

Chapter 6 of "Programming Flex 3" contains a detailed description of the Flex layout containers that I found very helpful.

Upvotes: 1

Mims H. Wright
Mims H. Wright

Reputation: 3037

I just read this article which covers layouts using Spark in a very clear language. It covers getPreferedWidth() and height specifically. http://www.adobe.com/devnet/flex/articles/spark_layouts.html

The author's blog is very useful too.

Upvotes: 0

Jörg Reichardt
Jörg Reichardt

Reputation: 361

Have a look at the measure() function of the component. (docs) This is the function to override if you want to change its default sizing behaviour.

EDIT: Be aware, that each component usually overrides the measure() function of UIComponent, so there is no single place to understand the layouting of flex. UIComponent gives you a starter, shows how the engine roughly works, but each component has its own concreate way of guessing the expected size. It does a remarkable job in a vast number of cases, but it's not so easy to get into it, if the magic doesn't work for you.

Upvotes: 0

Related Questions