Dispatching custom events

Flex defines many of the most common events, such as the click event for the Button control, however, your application may require that you create events. In your custom Flex components, you can dispatch any of the predefined events inherited by the component from its superclass, and dispatch new events that you define within the component.

To dispatch a new event from your custom component, you must do the following:

  1. (Optional) Create a subclass from the flash.events.Event class to create an event class that describes the event object. For more information, see Creating a subclass from the Event class.
  2. (Optional) Use the [Event] metadata tag to make the event public so that the MXML compiler recognizes it. For more information, see Using the Event metadata tag.
  3. Dispatch the event using the dispatchEvent() method. For more information, see Dispatching an event.

Subtopics

Creating a subclass from the Event class
Using the Event metadata tag
Dispatching an event
Creating static constants for the Event.type property

Flex 2

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/docs/00001643.html