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

18.3. Event Classes

As mentioned in the overview, you will be consolidating code that needs to be executed when the application loads in an event class and a command class, so you will need an event that gets dispatched when the application loads. You will also need events to load the recent posts and to allow the user to set the currently selected posts.

Start with the event that will be triggered when the application loads. In the com.FlexBlog.events package create a new event class named ApplicationInitializeEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.adobe.cairngorm.control.CairngormEvent;
    public class ApplicationInitializeEvent extends CairngormEvent
    {
        public static const INIT:String = 'applicationInitEvent';
        public function ApplicationInitializeEvent(bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(INIT, bubbles, cancelable);
        }
    }
}

This event simply triggers the corresponding command class and does not need to pass any data.

Next, move on to the event for loading the posts. In the com.FlexBlog.events package create a new event class named LoadRecentPostsEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.adobe.cairngorm.control.CairngormEvent;
    public class LoadRecentPostsEvent extends CairngormEvent
    {
        public static const LOAD:String = 'loadRecentPostsEvent';
        public function LoadRecentPostsEvent(bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(LOAD, bubbles, cancelable);
        }
    }
}

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