Another powerful approach to building your application, and one that works well when placing nested layout containers, is the constraints-based layout.
Think of constraints as an extension of the
BasicLayout. This makes sense because a component’s parent must be set up for absolute positioning in order for constraints to work. Essentially, constraints anchor a component a set distance, in pixels, from a corresponding position within its parent container. The effect of this layout tactic is most pronounced by resizing, which causes the constrained component to move relative to its anchor points.
The first four constraint properties correspond to the four edges of a rectangle:
right. For a quick example of how they’re used, look back at the color swatches code from earlier in the chapter; both the
Button and the
CheckBox were positioned using constraints.
There’s nothing mystical or deceptive about the constraint properties. It should be fairly obvious that
5" means “five pixels from the right, and five pixels from the bottom.”
Example 9-25. Using constraints to anchor components into the corners
library://ns.adobe.com/flex/spark" xmlns:mx=" ...