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

20.5. Command Classes

You need command classes for the keyword search and category search, and for clearing the search results.

Your search classes will need properties on the ModelLocator to represent the search title displayed to the user, and to hold the collection of posts returned by the search functions. Add the following to the FlexBlogModel:

public var searchTitle:String;
public var searchResults:ArrayCollection = new ArrayCollection();

Now create the command for the keyword search. In the com.FlexBlog.commands package create a new command class named KeyWordSearchCommand. Edit the class to match the following:

package com.FlexBlog.commands { import com.FlexBlog.delegates.KeyWordSearchDelegate; import com.FlexBlog.events.KeyWordSearchEvent; import com.FlexBlog.models.FlexBlogModel; import com.FlexBlog.valueobjects.UserNotificationVO; import com.adobe.cairngorm.commands.ICommand; import com.adobe.cairngorm.control.CairngormEvent; import mx.rpc.IResponder; import mx.rpc.events.ResultEvent; public class KeyWordSearchCommand implements ICommand, IResponder { private var model:FlexBlogModel = FlexBlogModel.getInstance(); private var keyWords:String; public function execute(event:CairngormEvent):void { this.model.searchTitle = "Searching ..." var evt:KeyWordSearchEvent = event as KeyWordSearchEvent; this.keyWords = evt.keyWords; var delegate:KeyWordSearchDelegate = new KeyWordSearchDelegate(this); delegate.search(this.keyWords); } public function result(data:Object):void { var ...

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