18.7. Implementation and Testing
Since the logic for what needs to occur when the application first loads has been moved to an event and command class, you are going to have to make some modifications to the MainView component to trigger the ApplicationInitializationEvent. While we are in there making modifications, we're going to make a few others regarding how views are being constructed to make the design more modular and organized.
If you continued simply adding views to the main view, this file could potentially get quite large. Part of the reason for using views is that you can, ideally, arrange them so that each view contains only the code to make that view operate. This keeps your view files simple and easy to deal with and also has the added benefit of making code related to specific views easy to find and update.
In order to keep the MainView component from getting too large, you are going to reorganize it by splitting it up into multiple views, which in turn will be made up of other views. Thus the MainView simply acts as a container that holds the sub-views. Adding another main view will simply be a matter of creating the sub-view component and adding it to the MainView as a direct child of the ViewStack component, and adding constants to the ChangeMainViewEvent to represent the new main view.
First you are going to address the new method of handling application initialization. Edit the init function of the MainView to match the following:
private function init():void{ ...
Get Professional Cairngorm™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.