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

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

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