![MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual Download Page 62](http://html1.mh-extra.com/html/macromedia/flex-developing-components-and-themes/flex-developing-components-and-themes_manual_3388115062.webp)
62
Chapter 3: Creating Advanced Components in Flash MX 2004
The
Bindable
keyword is required when you use the
ChangeEvent
metadata keyword. For more
information, see
“Bindable” on page 60
.
In the following example, the component generates the
change
event when the value of the
flavorStr
property changes:
[ChangeEvent("change")]
public var flavorStr:String;
When the event specified in the metadata occurs, Flash informs whatever is bound to the
property that the property has changed.
You can also instruct your component to generate an event when a getter or setter function is
called, as the following example shows:
[ChangeEvent("change")]
function get selectedDate():Date
In most cases, you set the
change
event on the getter function, and dispatch the event on the
setter function.
You can register multiple
change
events in the metadata so that more than one event is generated
when the property changes, as the following example shows:
[ChangeEvent("change1")]
[ChangeEvent("change2")]
[ChangeEvent("change3")]
Any one of those events indicates a change to the variable. They do not all have to occur to
indicate a change.
Effect
The
Effect
metadata keyword defines the name of the property that you can assign to an effect
for the MXML tag.
The
Effect
metadata keyword has the following syntax:
[Effect("
effect_name
")]
The
effect_name
generally matches the
event_name
listed in the
Effect
metadata plus the word
Effect
. The following example means that a tag may have a
resizeEffect
property assigned to
the effect to play when the resize event triggers:
[Effect("resizeEffect")]
Event
Use the
Event
metadata keyword to define events dispatched by this component. Add the Event
statements outside the class definition in the ActionScript file so that they are bound to the class
and not a particular member of the class.
The
Event
metadata keyword has the following syntax:
[Event("
event_name
")]