14.3. Main Application Setup

Now that you have your core classes created, it is time to add them to the FlexBlog.mxml main application file. Before you can do this, you will need to add some namespaces to the main application tag. Edit the main application tag as follows:

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlsn:views="com.FlexBlog.views.*" xmlns:controller="com.FlexBlog.controllers.*"
width="800" height="600">

These namespaces will enable you to access classes and MXML components from the views, controllers, and services packages.

Next, add the instances of the FrontController and ServiceLocator by adding the following to the main application:

<controller:FlexBlogController id="controller"/>

If you are new to using namespaces, note that instead of the mx: prefix used for standard Flex tags, the prefix for the FrontController matches the namespace you defined for the package that contains the component or class. The same will be true for the views package, as you will see shortly. You are free to use whatever namespaces you like in your own projects: they simply need to be unique in name and value.

Now that you have added the FrontController class to the main application, the FrontController class will be able to intercept and respond to any Cairngorm events that are dispatched.

Next you are going to create a main view component that will house your other views. In the com.FlexBlog.views package create a new component named MainView. ...

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.