User Guide

56 Using Metadata Tags in Custom Components
You insert the [Effect] metadata tag before the class definition in an ActionScript file, or in
the
<mx:Metadata> block in an MXML file. The [Effect] metadata tag has the following
syntax:
[Effect(name="eventNameEffect", event="eventName")]
The following table describes the properties of the [Effect] metadata tag:
The
[Effect] metadata tag is often paired with an [Event] metadata tag, where the
[Event] metadata tag defines the event corresponding to the effect’s trigger. By convention,
the name of the effect is the event name with the suffix
Effect, as the following example of
an ActionScript file shows:
// Define event corresponding to the effect trigger.
[Event(name="darken", type="flash.events.Event")]
// Define the effect.
[Effect(name="darkenEffect", event="darken")]
class ModalText extends TextArea {
...
}
In an MXML file, you can define the event and effect in an <mx:Metadata> block, as the
following example shows:
<mx:Metadata>
[Event(name="darken", type="flash.events.Event")]
[Effect(name="darkenEffect", event="darken")]
</mx:Metadata>
Event metadata tag
Use the [Event] metadata tag to define the MXML property for an event and the data type of
the event object that a component emits. You insert the
[Event] metadata tag before the class
definition in an ActionScript file, or in the
<mx:Metadata> block in an MXML file.
For more information on defining custom events, see Chapter 4, “Creating Custom Events,
on page 35.
The
[Event] metadata tag has the following syntax:
[Event(name="eventName", type="package.eventType")]
Property Type Description
eventNameEffect
String Specifies the name of the effect.
eventName
String Specifies the name of the event that triggers the effect.