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

22.4. Revising Adding a Post

Adding a post is currently accomplished with the following classes:

  • AddPostEvent

  • AddPostDelegate

  • AddPostCommand

  • LoadCategoriesEvent

  • LoadCategoriesCommand

  • LoadCategoriesDelegate

The AddPostEvent will become a type of the new PostEvent class.

The addPost function of the AddPostDelegate will move to the new PostDelegate class.

The AddPostCommand will be updated to cast the event as a PostEvent and use the new PostDelegate.

The LoadCategoriesEvent will become a type of the CategoryEvent class.

The loadCategories function of the LoadCategoriesDelegate will be moved to the CategoryDelegate class.

The execute function of the LoadCategoriesCommand will be updated to use the CategoryDelegate.

Start with the new event class for posts. In the com.FlexBlog.events package create a new event class named PostEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.FlexBlog.valueobjects.PostVO;
    import com.adobe.cairngorm.control.CairngormEvent;
    public class PostEvent extends CairngormEvent
    {
        public static const ADD:String = 'addPostEvent';
        public var post:PostVO;
        public function PostEvent(type:String, post:PostVO = null,
        bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
            this.post =post;
        }
    }
}

Now create the new post delegate class. In the com.FlexBlog.delegates package create a new delegate class named PostDelegate. Edit the class to match the following:

package com.FlexBlog.delegates { import com.FlexBlog.valueobjects.PostVO; ...

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