| Creating and Extending Flex 2 Components > Creating Custom Flex Components > Creating Custom Events > Dispatching custom events > Dispatching an event | |||
You use the dispatchEvent() method to dispatch an event. The dispatchEvent() method has the following signature:
public dispatchEvent(event:Event):Boolean
This method requires an argument of type Event, which is the event object. The dispatchEvent() method initializes the target property of the event object with a reference to the component dispatching the event.
You can create an event object and dispatch the event in a single statement, as the following example shows:
dispatchEvent(new Event("click"));
You can also create an event object, initialize it, and then dispatch it, as the following example shows:
var eventObj:EnableChangedEvent = new EnableChangedEvent("enableChanged");
eventObj.isEnabled=true;
dispatchEvent(eventObj);
For complete examples that create and dispatch custom events, see Creating Advanced MXML Components and Creating Simple Visual Components in ActionScript.
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/00001646.html