views:

113

answers:

3

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.

A: 

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.

Jörg Reichardt
But measure() needs to be able to tell what sizes the child components want to be. And measure() is protected, so I can't call it on other components to get them to do the calculations. I'm really looking for some good overview documentation on how the entire system (measure, the various size properties, invalidateSize, etc) ties together and is expected to work.
Herms
I'm sorry, I really meant to look at the function, i.e. the source, it's open source after all. I know, it's not really an overview, but this is where I would/will look if/when I need to implement my own layouting. Until now I have procrastinated successfully this tricky copmlex, but I know the day will come where I have to do this, too. And the source is, where you can see how it really works.
Jörg Reichardt
I did look at the source. It gave me some ideas, but I'm still guessing about a lot of stuff.
Herms
A: 

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%5Flayouts.html

The author's blog is very useful too.

Mims H. Wright
Sadly that appears to be Flex 4 only, and I'm working in 3.
Herms
+1  A: 

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

Pieter Kuijpers
That sounds like what I'm looking for. Thanks for providing a Safari link, that saved me a lot of trouble tracking it down. :)
Herms