1 Reply Latest reply on Dec 4, 2006 8:07 AM by OlivierS

    Cairngorm Event typing

    David_S_deB Level 1
      A cairngorm 2.1 question.

      When we create a new event we extend the Cairngorm event class, add what ever properties and add it to the Application controller. My question is when we create the command for this new event why do we specify the event type in the command definition as type Cairngorm event, only to cast it to the newly created event on the following line? EG (from the CG store 2.1)


      public class SortProductsEvent extends CairngormEvent
      public static var EVENT_SORT_PRODUCTS : String = "sortProducts";
      public var sortBy : String;
      * Constructor.
      public function SortProductsEvent()
      super( EVENT_SORT_PRODUCTS );
      * Override the inherited clone() method, but don't return any state.
      override public function clone() : Event
      return new SortProductsEvent();


      public function execute( event : CairngormEvent ) : void
      var sortEvent : SortProductsEvent = SortProductsEvent( event );

      var sortBy : String = sortEvent.sortBy;
      var model : ShopModelLocator = ShopModelLocator.getInstance();

      var sort : Sort = new Sort();

      Would it not be simpler to change the method definition to:

      public function execute( event : SortProductsEvent ) : void



      Is there a better place to ask Cairngorm Questions? cairngormdocs.org doesn´t have a forum.