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

24.2. Revising Commenting

To understand the use of the SequenceCommand class, you are now going to revise the commenting system to use this class to refresh the comment lists when someone makes a comment.

Make the following modifications to the AddCommentCommand:

  1. Change the class definitions to extend SequenceCommand and implement IResponder:

    public class AddCommentCommand extends SequenceCommand implements IResponder
  2. Make sure Flex updated the import statements for you.

  3. Add a constructor that assigns a CommentEvent to the nextEvent property. Note that you are only creating the event here and not dispatching it:

    this.nextEvent =  new CommentEvent(CommentEvent.LOAD,
                this.model.currentPost);
            }
  4. Add the override keyword to the execute function:

    override public function execute(event:CairngormEvent):void
  5. Update the result function to call the executeNextCommand method rather than directly dispatching a CommentEvent:

    public function result(data:Object):void
            {
                var evt:ResultEvent = data as ResultEvent;
                if (evt.result.added == 1){
                    this.model.commentSubmissionStatus ='success'
                    this.executeNextCommand();
                }
            }
  6. Debug the application, log in with the poe account (user name = poe, password = password) and make a new comment on the currently displayed post. Your screen should look like (Figure 24-1), with the comment you made showing up in the list.

    Figure 24.1. figure 24-1

If you did not get the expected ...

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