views:

104

answers:

3

I have an application with width/height of 100%. I have several nested groups within and their measurements are all not set, instead being defined as top=5 or left/right=10, etc.

I'm trying to get the actual with of a group that should be 390. I've set the swf object size to be 400 from the html embed code, and the group is inside another group that is width=100%. The group has a left=5 and right=5 so the width should be 400-10. When I display the .width and .measuredWidth of this group, the width is always 400.

I'm fairly new to flex/flash. Do I need to have explicitly set widths in order to get the width of child containers? Is there something I'm doing wrong here?

Thanks!

A: 

I believe that it's returning the right value. If you have an application A, width 400. Then you put group B inside it with width 100% and some padding. Group B really is 400, because it's extended all the way to the edges of the application. However, by giving it left/right/padding/whatever, it, in turn, can adjust its children so they aren't so close to the edges. You may need to look for the maximum width of group B's children to get what you want.

Update:

According to documentation:

http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_5.html

Using constraint-based layouts overrides width and percentWidth. Try measuredWidth, though it may not be filled until the component has had time to go through its measure() phase during invalidation...

eruciform
Sorry if I was unclear. Group B doesn't have padding, it has the properties left=5 and right=5 which aren't padding properties, it's using constraint based layout and anchoring the inner group to the outer group.
Amy
updated answer...
eruciform
+1  A: 

Use the getExplicitOrMeasuredWidth() method of the UIComponent. This returns the explicit width if set (e.g., width="700") or the measured width (in pixels) if not. If a percentage width is set, it returns the actual measured width.

Robusto
A: 

It turns out there was an inner group with a path that was throwing the layout off. When I removed this element, the .width property worked as it had before.

One thing that surprised me is that .measuredWidth and getExplicitOrMeasuredWidth() both returned 10 when .width returned 390.

Amy