November 2009
Intermediate to advanced
357 pages
8h 20m
English
You need a command class for the loading of the categories and for adding a post. Start with the command class for loading the categories.
You will need to store the categories that are loaded in a property on the ModelLocator. Add the following to the FlexBlogModel:
public var categories:ArrayCollection = new ArrayCollection();
Make sure that Flex has added the import for the ArrayCollection class.
Next, in the com.FlexBlog.commands package create a new command class called LoadCategoriesCommand. Edit the class to match the following:
package com.FlexBlog.commands
{
import com.FlexBlog.delegates.LoadCategoriesDelegate;
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 LoadCategoriesCommand implements ICommand, IResponder
{
private var model:FlexBlogModel = FlexBlogModel.getInstance();
public function execute(event:CairngormEvent):void
{
var delegate:LoadCategoriesDelegate = new LoadCategoriesDelegate(this);
delegate.loadCategories()
}
public function result(data:Object):void
{
var evt:ResultEvent = data as ResultEvent;
var notification:UserNotificationVO = new UserNotificationVO();
if (evt.result.categories){
this.model.categories.source = evt.result.categories;
}
}
public function fault(info:Object):void
{
}
}
}
The execute function simply calls ...