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

16.3. Event Classes

You will need an event class for both the login and logout functionality.

Start with the login event by creating a new event class named LoginEvent in the com.FlexBlog.events package. Edit it to match the following:

package com.FlexBlog.events
{
    import com.FlexBlog.valueobjects.UserVO;
    import com.adobe.cairngorm.control.CairngormEvent;
    public class LoginEvent extends CairngormEvent
    {
        public static const LOGIN:String = "loginEvent";
        public var user:UserVO;
        public function LoginEvent(user:UserVO, bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(LOGIN, bubbles, cancelable);
            this.user =user;
        }
    }
}

The LoginEvent takes in a UserVO that it will pass along to the LoginCommand. This UserVO will simply have the userName and password properties populated so that they can be used to locate the account in the delegate class.

Next, create the logout event by creating a new event class named LogoutEvent in the com.FlexBlog.events package. Edit it to match the following:

package com.FlexBlog.events
{
    import com.adobe.cairngorm.control.CairngormEvent;
    public class LogoutEvent extends CairngormEvent
    {
      public static const LOGOUT:String = 'logoutEvent';
      public function LogoutEvent(bubbles:Boolean=false, cancelable:Boolean=false)
      {
            super(LOGOUT, bubbles, cancelable);
        }
    }
}

This event does not need to transfer any data and is only being used to trigger the corresponding command class that will handle the login procedure.

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