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

22.3. Revising Login

Login and logout are currently accomplished with the following classes:

  • LoginEvent

  • LogoutEvent

  • LoginDelegate

  • LoginCommand

  • LogoutCommand

The LoginEvent and LogoutEvent will be replaced with types on the UserEvent class.

The login function of the LoginDelegate will be moved to the UserDelegate.

The LoginCommand will be updated to cast the event as a UserEvent and use the new UserDelegate.

The LogoutCommand does not make use of a delegate, nor does it reference any data passed in by the event class, so it will remain as is.

Start by updating the UserEvent class by adding the following two constants:

public static const LOGIN:String = 'loginEvent';
public static const LOGOUT:String = 'logoutEvent';

Now move the login function from the LoginDelegate class to the UserDelegate class. It should now look as follows:

package com.FlexBlog.delegates { import com.FlexBlog.valueobjects.UserVO; import flash.errors.SQLError; import mx.rpc.IResponder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import sql.FlexBlogDatabaseManager; public class UserDelegate { private var responder:IResponder; public function UserDelegate(responder:IResponder) { this.responder =responder; } public function register(user:UserVO):void{ var dbManager:FlexBlogDatabaseManager = FlexBlogDatabaseManager.getInstance(); try{ var userAdded:int = dbManager.registerUser(user); var event:ResultEvent = new ResultEvent(ResultEvent.RESULT,false,true,{added:userAdded}) this.responder.result(event) ...

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