Flex/AIR: DynamicEvent
Jan 10
Web Development & Design ActionScript, AIR, Flex View Comments
Applies to: Adobe Flex & AIR
A DynamicEvent is a type of custom event in Flex that is easier and quicker to set up than the full-blown approach. By applying the latter method, you normally go through the following steps:
- Define a subclass from flash.events.Event
- Make the event available to other ActionScript (through addEventListenter()) components or MXML components (using the [Event] metatag)
- Dispatch the event, using dispatchEvent()
Full documentation on custom events can be found in Adobe’s LiveDocs, here.
Generally one uses the above approach when you need to pass arguments to the code that’s targeted by the event. When you don’t require this, however, you can opt for the DynamicEvent. It’s not necessary to go through the whole rigamarole of subclassing; all you need is a name for the event, like so:
var yourEvent:DynamicEvent = new DynamicEvent("yourEventName", true);
dispatchEvent(yourEvent);The second argument set to true means the event will bubble.
RSS


Latest Comments