19.3. Event Classes

You need event classes both for loading comments and for adding a comment.

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

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

This event takes in a PostVO that gets passed to the command class so that the postId property can be used to load the corresponding comments.

Next, create the event for adding a comment. In the com.FlexBlog.events package create a new event class named AddCommentEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.FlexBlog.valueobjects.CommentVO;
    import com.adobe.cairngorm.control.CairngormEvent;
    public class AddCommentEvent extends CairngormEvent
    {
        public static const ADD:String = 'addCommentEvent';
public var comment:CommentVO;
        public function AddCommentEvent(comment:CommentVO, bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(ADD, bubbles, cancelable);
            this.comment =comment;
        }
    }
}

This event takes in a CommentVO object that gets passed to the command class so that the comment ...

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.