flex cairngorm addComand not work

387 views Asked by At

Hey everybody) I need help with the understanding of the framework Cairngorm for flex.

I code a simple application slider. I have a main class in which I have a tag

<fx:Declarations>
    <control:AppController id="appController" />
</fx:Declarations>

Class itself AppController extends FrontController with constructor function:

public function AppController()
    {
        addCommand(SliderEvent.BUILD, SliderBuildCommand);
        addCommand(SliderEvent.TRANSITION, SliderTransitionCommand);
    }

and finally the code of SliderBuildCommand class:

 public function SliderBuildCommand(){}

    public function execute(event:CairngormEvent):void
    {
        config.loadSlides(this);
    }

Unfortunately, in debugging, I see that the addition of the command didn't work out. This can be seen if set a breakpoint in "сonfig.loadSlides(this)" line. However, the command (addCommand) is processed. Any idea why this is happening? Maybe I am a noob and I don't see the obvious :)

1

There are 1 answers

3
Asad On

Instead of adding/mapping commands in AppController's constructor. Declare it in initialize() function. Example is given below for your reference.

public class AppController extends FrontController
    {
        public function AppController()
        {
            super();
        }

        public function initialize():void
        {
            this.addCommand(SliderEvent.BUILD, SliderBuildCommand);
            this.addCommand(SliderEvent.TRANSITION, SliderTransitionCommand);
        }
    }