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

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