O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required