User Guide

164 Creating Advanced Visual Components in ActionScript
You can override the default size settings in an application, as the following example shows:
<?xml version="1.0"?>
<!-- asAdvanced/MainBlueButtonResize.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<mx:VBox>
<MyComp:BlueButton width="50%"/>
<mx:Button/>
</mx:VBox>
</mx:Application>
In this example, you specify that the width of the button is 50% of the width of the VBox
container. When 50% of the width if the container is smaller than the minimum width of the
button, the button uses its minimum width.
Calculating default sizes
The example in “Implementing the measure() method” on page 162 uses static values for the
default size and default minimum size of a component. Some Flex components use static sizes.
For example, the Te x tA re a control has a default size of 100 pixels wide by 44 pixels high,
regardless of the text it contains. If the text is larger than the TextArea control, the control
displays scroll bars.
Often, you set the default size based on characteristics of the component or information
passed to the component. For example, the Button control’s
measure() method examines its
label text, margin settings, and font characteristics to determine the control’s default size.