tags:

views:

66

answers:

2

Are there any libraries out there which will help me style a Flex application without going insane?

For example, is there any "accepted" way to set an element's size/position without hard-coding it into each element?

A: 

You can use VBox and HBox components that layout the children either vertically or horizontally. I would avoid nesting this too much because it will affect your applications performance.

Shua
Let's say I want to do this: <VBox><Label A> <Label B> <Label C></VBox>. Without individually setting the width property on each of those labels there is no way (without dropping into ActionScript) to say "make all the labels below that VBox have a width of 100".
David Wolever
I gotcha...you can do what brd6644 says below or just extend the label class and override the width so its 100% or the desired width.
Shua
Well, yes, I could do it that way... But I was hoping for something cleaner :( Or maybe I just need to adjust my definition of "clean"...
David Wolever
+2  A: 

The width, height and position of elements are not styles, they are properties. Unfortunately they can't be set via a stylesheet.

What you could do is extend one of the Container classes and override the childrenCreated() method, access the elements in the "children" Array and set the values you want.

cliff.meyers
Hrm, yea... I've learned that Flex doesn't consider positioning information "style"... Oh well. I guess this is just "something to live with"?
David Wolever
Due to the nature of the UIComponent lifecycle (which uses methods such as measure() and updateDisplayList() to dynamically determine size / positioning ) it's not something that can easily be solved in the way you suggest. If you have a ton of screens that need to be laid out in a consistent manner, I really would recommend creating a custom Container to do this for you. Learning the intricacies of the UIComponent lifecycle will put you in the top 5-10% of Flex developers; most don't understand it at all.
cliff.meyers
I should add that there are some styles that can affect the positioning of child elements such as the horizontal/verticalGap and top/bottom/let/rightPadding styles of the Box component. If you look at the source for BoxLayout you'll see how these are used to control positioning of children. Writing a custom component that makes use of similar layout styles might help you.
cliff.meyers