User Guide
248 Creating Effects
// Define the private variable for the bright setting.
private var _bright:Boolean = true;
// Define the setter to dispatch the events
// corresponding to the effect triggers.
public function set bright(value:Boolean):void {
_bright = value;
if (_bright)
dispatchEvent(new Event("brighten"));
else
dispatchEvent(new Event("darken"));
}
// Define the getter to return the current bright setting.
public function get bright():Boolean {
return _bright;
}
]]>
</mx:Script>
</mx:Button>
When you declare an event in the form [Event(name="eventName",
type="package.eventType")]
, you can also create a corresponding effect, in the form
[Effect(name="eventnameEffect", event="eventname")]. As in the previous example,
in the
<mx:Metadata> tag, you insert the metadata statements that define the two new events,
darken and brighten, and the new effect triggers, darkenEffect and brightenEffect, to
the Flex compiler.
For more information on using metadata, see Chapter 5, “Using Metadata Tags in Custom
Components,” on page 45.