November 2009
Intermediate to advanced
357 pages
8h 20m
English
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 ...