For those readers who are not familiar with the architecture of the AS3-Layout-Framework, here is a short introduction.
Which base class should you use?
The answer is very simple. If the needed component has no subcomponents, use Component. If other components should be added and also be laid out, use Container instead.
Which methods should you override?
There are only two methods that need to be overridden: measure and arrange.
During the measuring phase a container has the possibility to set its measured sizes (measuredMinimumWidth/measuredMinimumHeight and measuredDesiredWidth/measuredDesiredHeight) to the sizes of its child components. These sizes are only recognized by the parent container, if the minimum or desired size are not set explicitly.
During the arrange phase a Component can handle its new bounds and a Container can lay out its child components.
Which sizes should you set?
There are 3 explicit and 2 measured width and height couples in a Component.
Explicit sizes: minimumWidth/minimumHeight, desiredWidth/desiredHeight, desiredPercentWidth/desiredPercentHeight, maximumWidth/maximumHeight.
Measured sizes: measuredMinimumWidth/measuredMinimumHeight, measuredDesiredWidth/measuredDesiredHeight.
The desired size is the size of how the Component wants to be laid out. The minimum/maximum size declares the smallest/biggest size a Component is accepting.
The default values of minimum size is 0/0 for width and height settings and those of maximum size are int.MAX_VALUE/int.MAX_VALUE.
NOTE:IContainer implementations should pay attention to those sizes being set by a component when it comes to lay out their child components.
The following example demonstrates a sceleton implemenation of a custom Component:
package { import com.addicted2flash.layout.core.Component; /** * @author Tim Richter */ public class TestUIComponent extends Component { public function TestUIComponent( ) { } override public function measure(): void { // -- measure minimum/desired size here } override public function arrange(): void { // -- update size here } } }