22.6. Revising Commenting

The commenting system is currently accomplished with the following classes:

  • AddCommentEvent

  • AddCommentDelegate

  • AddCommentCommand

  • LoadCommentsEvent

  • LoadCommentsDelegate

  • LoadCommentsCommand

The AddCommentEvent and LoadCommentsEvent will become properties of the CommentEvent class. As mentioned earlier, these two types of events currently expect different value objects, so the type of the property holding the data to be passed will have to be typed as Object to accommodate different types of value objects.

The addComment function of the AddCommentDelegate and the loadComments function of the LoadCommentsDelegate will be moved to the CommentDelegate class.

The AddCommentCommand will be updated to cast the event as a CommentEvent and both the AddCommentCommand and the LoadCommentsCommand will be updated to use the CommentDelegate class.

Start by creating the new comment event. In the com.FlexBlog.events package create a new event class named CommentEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.adobe.cairngorm.control.CairngormEvent;
    public class CommentEvent extends CairngormEvent
    {
        public static const ADD:String = 'addCommentEvent';
        public static const LOAD:String = 'loadCommentsEvent';
        public function CommentEvent(type:String, data:Object = null,
bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
            this.data = data;
        }
    }
}

Here is the first case in which the constructor is being designed ...

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.