Home > Flex > Panel border dimensions

Panel border dimensions

October 21, 2007

I’ve received a couple questions regarding custom Flex components (in Actionscript) and how to position child elements relative to the parent borders.  For example, consider a component extending Panel that contains Text and Button child items.  The Text control is to be placed near the top-left of the content area and its width is relative to the width of the content area.  The (0,0) coordinate represents the top, left-hand corner of the Panel, not the content area.  To position children relative to the content area, it is necessary to know the border dimensions.

If the parent container extends mx.core.Container, you might consider using the viewMetrics property, which returns an instance of mx.core.EdgeMetrics.  The EdgeMetrics instance contains four properties (bottom, left, right, top) containing the extents of the borders surrounding the content area.

If you are just starting out with custom Actionscript components for Flex, maybe this will help you out.  Good luck!

Advertisements
Categories: Flex
%d bloggers like this: