Style
The
metadata keyword describes a style property allowed for the component. The
Style
metadata keyword has the following syntax:
[Style(name=style_name[,option=value,...])]
The following table describes the options for the
Option
Type
String
name
String
type
format
String
inherit
String
The following example shows the
[Style(name="textSelectedColor",type="Number",format="Color",inherit="yes")]
Defining component parameters
When building a component, you can add parameters that define its appearance and behavior.
The most commonly used properties appear as authoring parameters in the Component
inspector. You define these properties by using the
on page
63). You can also set all inspectable parameters with ActionScript. Setting a parameter
with ActionScript in your MXML application overrides any value set during component
authoring.
The following examples set several component parameters and expose them with the
metadata keyword in the Component inspector:
Inspectable
// A string parameter.
[Inspectable(defaultValue="strawberry")]
public var flavorStr:String;
// A string list parameter.
[Inspectable(enumeration="sour,sweet,juicy,rotten",defaultValue="sweet")]
public var flavorType:String;
// An array parameter.
[Inspectable(name="Flavors", defaultValue="strawberry,grape,orange",
verbose=1, category="Fruits")]
var flavorList:Array;
// An object parameter.
[Inspectable(defaultValue="belly:flop,jelly:drop")]
public var jellyObject:Object;
// A color parameter.
[Inspectable(defaultValue="#ffffff")]
public var jellyColor:Color;
66
Chapter 3: Creating Advanced Components in Flash MX 2004
Description
(Required) The name of the style.
The type of data.
Units of the property.
Whether the property is inheriting. Valid values are
textSelectedColor
metadata keyword:
Style
property:
keyword (see
Inspectable
Style
and
.
yes
no
"Inspectable"
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