I've tried both creating commands in the result handler and by using
the Task framework. I like the Task framework because it's more
modular in that it helps keep the commands independent. Having said
that, I'm having problems getting it working.

I created a task per command and each task dispatches the message for
the command and wait for the results. Then I've created a sequential
task group and added each task and then start the group. Here is an
example of one of my tasks:-

package mytasks
    import org.spicefactory.lib.task.Task;
    import org.spicefactory.parsley.asconfig.ActionScriptContextBuilder;

    import MyMessage;
    import MyModel;

    public class MyTask extends Task
        [Inject(id="myModel")] [Bindable]
        public var myModel:MyModel;

        public var messageDispatcher:Function;

        public function MyTask()

        protected override function doStart():void {
            messageDispatcher(new MyMessage());

        public function handleMyMessage(message:MyMessage):void {
            if (message.success == true) {
                myModel.debug = "success";
            } else {
                error("my task failed");


And my configuration file contains:-

<model:MyModel id="myModel"/>
<spicefactory:DynamicCommand type="{MyCommand}" selector="execute"
result="handleResult" error="handleError"/>

My command is:-

package mycommands
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    import mx.rpc.AsyncToken;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;

    import MyMessage;
    import MyModel;

    public class MyCommand {

        public var service:RemoteObject;

        public var myModel:MyModel;

        public function execute (message:MyMessage) : AsyncToken {
            return service.getRemoteData(myModel.id);

        public function handleResult(result:ResultEvent,
message:MyMessage):void {
            if (result.result != null) {
                myModel.dataCollection = result.result as ArrayCollection;
                message.success = true;

        public function handleError(fault:FaultEvent, trigger:MyMessage):void {

But when I run this I get "value is not a function".

So what have I missed or left out?

Chris Velevitch
Manager - Adobe Platform Users Group, Sydney
m: 0415 469 095

Adobe Platform Users Group, Sydney
Topic: Deploying Coldfusion into the Cloud
Date: 26th September 6pm for 6:30 start
Details and RSVP on

Reply via email to