User Guide
Implementing the component 163
Component users can also override the default size settings in an application by using the
component in the following ways:
■ Setting the explicitHeight and exlicitWidth properties
■ Setting the width and height properties
■ Setting the percentHeight and percentWidth properties
For example, you can define a Button control with a default size of 100 pixels wide and
50 pixels tall, and a default minimum size of 50 pixels by 25 pixels, as the following example
shows:
package myComponents
{
// asAdvanced/myComponents/DeleteTextArea.as
import mx.controls.Button;
public class BlueButton extends Button {
public function BlueButton() {
super();
}
override protected function measure():void {
super.measure();
measuredWidth=100;
measuredMinWidth=50;
measuredHeight=50;
measuredMinHeight=25;
}
}
}
The following application uses this button in an application:
<?xml version="1.0"?>
<!-- asAdvanced/MainBlueButton.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<mx:VBox>
<MyComp:BlueButton/>
<mx:Button/>
</mx:VBox>
</mx:Application>
In the absence of any other sizing constraints on the button, the VBox container uses the
default size and default minimum size of the button to calculate its size at run time. For
information on the rules for sizing a component, see Chapter 13, “Introducing Containers,”
in Flex 2 Developer’s Guide.