O'Reilly logo

Flex 3 Cookbook by Joshua Noble, Todd Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Containers

The term containers generally refers to all the classes held in the mx.containers package of the Flex Framework. Containers extend the UIComponent class, adding layout management functionality, methods to control the creation of children using creation policies, and automatic scrolling. The implementations of containers are quite distinct, but all share the ability to position children, lay out those children by using constraints or styles, and control scrolling and how those children respond to scroll events.

Constraints are new to Flex 3. They enable developers to create rules for positioning, in terms of both location and sizing, to which the children of containers can be assigned. Constraints work only with containers, such as the Canvas container, that have absolute positioning, which has much the same meaning as it does in CSS. Box and Tile containers provide automatic layout of children and methods for controlling which children are included in the layout management.

3.1. Position Children by Using Layout Management

Problem

You need to position multiple children vertically or horizontally and control the layout of those children.

Solution

Use the HBox or VBox container, and set the horizontalGap or verticalGap for the HBox or VBox, respectively, to set the distance between the components.

Discussion

Extending the common base class mx.containers.Box, the HBox and VBox components lay out their children horizontally or vertically, respectively, and can hold an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required