}
function init() {
setStyle("fontSize", 24);
super.init();
invalidate();
}
function measure() {
_measuredPreferredWidth=500;
_measuredPreferredHeight=200;
}
}
The following MXML file instantiates the BlueButton control. All instances of this BlueButton
control have a default size of 500 by 200 pixels, with a label
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*" >
<BlueButton label="My Big Button" />
</mx:Application>
You can override custom style settings in the MXML file, as the following example shows:
<BlueButton label="My Big Button" fontSize="12" />
Styling custom components
Style properties define the look of a component, from the size of the fonts used to the color of the
background. To change style properties in custom components, use the
the component's
but Flex application authors can override the settings of the
tags. Any style properties that are not explicitly set in the component's class file are inherited from
the component's superclass.
This section includes a class file that extends an existing control. For more information on setting
up the Flash environment and exporting this custom component as a SWC file, see
Blue Button" on page
The following ActionScript class file sets the
control:
class BlueButton extends mx.controls.Button {
static var symbolName:String="BlueButton";
static var symbolOwner:Object = BlueButton;
var className:String = "BlueButton";
function BlueButton() {
}
function init() {
// Set the label text to blue.
38
Chapter 2: Creating Basic Components in Flash MX 2004
function. This applies the same style to all instances of the component,
init()
27.
fontSize
setStyle()
and
color
themeColor
of 24.
method in
setStyle()
method in their MXML
"Creating the
styles of the BlueButton
Need help?
Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?
Questions and answers