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

27.6. Create a New Command

Creating a new command actually does several things:

  • Creates a command class.

  • Creates an event class.

  • Registers the event and command class in the default controller.

To create a new command, do the following:

  1. Right-click your project in the Flex Navigator and select New Cairngorm Command (Figure 27-29).

    Figure 27.29. Figure 27-29
  2. In the New Cairngorm Event and Command dialog (Figure 27-30) do the following:

    1. Enter a name for the event in the Event name field.

    2. Enter the event class name in the Event class field.

    3. Enter the command class name in the Command class field.

    4. Click Finish.

Figure 27.30. Figure 27-30

The process generates the following classes:

LoginEvent:

package com.cairngormplugin.events
{
   import com.adobe.cairngorm.control.CairngormEvent;
   import flash.events.Event;
   public class LoginEvent extends CairngormEvent
   {
      public static const EVENT_NAME : String = "login";
      public function LoginEvent( bubbles : Boolean = false,
      cancelable : Boolean = false )
      {
         super( EVENT_NAME, bubbles, cancelable );
}
      public override function clone() : Event
      {
         return new LoginEvent( bubbles, cancelable );
      }
   }
}

LoginCommand:

package com.cairngormplugin.commands { import com.adobe.cairngorm.commands.Command; ...

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