Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Until now, you’ve concentrated on building rich components for a business framework. We Flex architects also recommend some coding techniques that serve the same goal as these components: enabling application developers to write less code. In this section, you’ll see how to minimize the number of custom event classes in any application.
Flex is all about event-driven development. Create loosely coupled custom components and let them send events to each other, as in the mediator pattern example from Chapter 2. You can create new events for every occasion. If an event does not need to carry any additional data, just give it a name, specify its type as flash.events.Event, and define the meta tag to help Flash Builder list this event in its type-ahead prompts and dispatch it when appropriate. If your new event needs to carry some data, create an ActionScript class extending flash.events.Event, define a variable in this subclass to store application data, and override the method clone().