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

Writing the component’s ActionScript code 61
Use the Bindable metadata keyword to make properties and getter and setter functions in your
ActionScript classes appear on the Bindings tab in the Component inspector.
The
Bindable metadata keyword has the following syntax:
[Bindable[readonly|writeonly[,type="datatype"]]]
The Bindable keyword must precede a property, a getter or setter function, or other metadata
keyword that precedes a property or getter or setter function.
The following example defines the property
flavorStr as a public, inspectable variable that is
also accessible on the Bindings tab in the Component inspector:
[Bindable]
[Inspectable(defaultValue="strawberry")]
public var flavorStr:String = "strawberry";
The Bindable metadata keyword takes three options that specify the type of access to the
property, as well as the data type of that property. The following table describes these options:
You can combine the access option and the data type option, as the following example shows:
[Bindable(param1="writeonly",type="DataProvider")]
The Bindable keyword is required when you use the ChangeEvent metadata keyword. For more
information, see “ChangeEvent” on page 61.
ChangeEvent
Use the ChangeEvent metadata keyword to generate one or more component events when
changes are made to properties.
The
ChangeEvent metadata keyword has the following syntax:
[ChangeEvent("event_name"[,...)]
property_declaration or get/set function
You can use this keyword only with variable declarations or getter or setter functions, although it
is not required.
Option Description
readonly
Instructs Flash to allow the property to be only the source of a binding, as this
example shows:
[Bindable("readonly")]
writeonly
Instructs Flash to allow the property to be only the destination of a binding, as
this example shows:
[Bindable("writeonly")]
type="datatype"
Specifies the data type of the property that is being bound. If you do not specify
this option, data binding uses the property’s data type as declared in the
ActionScript code.
If
datatype is a registered data type, you can use the functionality in the Schema
tab’s Data Type pop-up menu.
The following example sets the data type of the property to String:
[Bindable(type="String")]