User Guide
166 Creating Advanced Visual Components in ActionScript
Implementing the layoutChrome() method
The Container class, and some subclasses of the Container class, use the layoutChrome()
method to define the border area around the container.
Flex schedules a call to the
layoutChrome() method when a call to the
invalidateDisplayList() method occurs. The layoutChrome() method executes during
the next
render event after a call to the invalidateDisplayList() method. When you use
the
addChild() method to add a component to a container, Flex automatically calls the
invalidateDisplayList() method.
Typically, you use the RectangularBorder class to define the border area of a container. For
example, you can create the RectangularBorder object, and add it as a child of the component
in your override of the
createChildren() method.
When you create a subclass of the Container class, you can use the
createChildren()
method to create the content children of the container; the content children are the child
components that appear within the container. You then use
updateDisplayList() to
position the content children.
You typically use the
layoutChrome() method to define and position the border area of the
container, and any additional elements that you want to appear in the border area. For
example, the Panel container uses the
layoutChrome() method to define the title area of the
panel container, including the title text and close button.
The primary reason for dividing the handling of the content area of a container from its
border area is to handle the situation when the
Container.autoLayout property is set to
false. When the autoLayout property is set to true, measurement and layout of the
container and of its children are done whenever the position or size of a container child
changes. The default value is
true.
When the
autoLayout property is set to false, measurement and layout are done only once,
when children are added to or removed from the container. However, Flex executes the
layoutChrome() method in both cases. Therefore, the container can still update its border
area even when the
autoLayout property is set to false.
Implementing the updateDisplayList() method
The updateDisplayList() method sizes and positions the children of your component
based on all previous property and style settings, and draws any skins or graphic elements that
the component uses. The parent container for the component determines the size of the
component itself.