User Guide
Table Of Contents
- Contents
- Working with Flash MX 2004
- Creating Basic Components in Flash MX 2004
- Creating Advanced Components in Flash MX 2004
- Contents
- About Creating components
- Writing the component’s ActionScript code
- Simple example of a class file
- General process for writing a class file
- Selecting a parent class
- Identifying the class, symbol, and owner names
- About the component instantiation life cycle
- Writing the constructor
- Specifying clip parameters
- Implementing the constructObject2() method
- Implementing the init() method
- Implementing the createChildren() method
- Implementing the commitProperties() method
- Implementing the measure() method
- Implementing the layoutChildren() method
- Implementing the draw() method
- Defining getters and setters
- Component metadata
- Defining component parameters
- Handling events
- Using the Event metadata
- About invalidation
- Skinning custom controls
- Adding styles
- Making components accessible
- Improving component usability
- Best practices when designing a component
- Using the ModalText example
- Troubleshooting
- Index

66 Chapter 3: Creating Advanced Components in Flash MX 2004
Style
The Style 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 Style metadata keyword:
The following example shows the
textSelectedColor property:
[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
Inspectable keyword (see “Inspectable”
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
Inspectable metadata keyword in the Component inspector:
// 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;
Option Type Description
name
String (Required) The name of the style.
type
String The type of data.
format
String Units of the property.
inherit
String Whether the property is inheriting. Valid values are yes and no.