My Events:

package com.isavepets.rm.events
{
    import flash.events.Event;

    public class LoginEvent extends Event
    {

        public static const LOGIN:String = "loginEvent";
        public static const LOGOUT:String = "logoutEvent";
        public static const FAILED:String = "loginAttemptFailedEvent";

        public var username:String;
        public var password:String;

        public function LoginEvent(type:String, bubbles:Boolean=true, 
cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
        }

    }
}

My Listener on the LoginPanel component View:

    public function attemptLogin(username:String, password:String):void {
                this.addEventListener(LoginEvent.FAILED, loginFailed);
                var login:LoginEvent = new LoginEvent(LoginEvent.LOGIN);
                login.username = username;
                login.password = password;
                dispatchEvent(login);
            }

----------------------------------------
From: "Tracy Spratt" <[email protected]>
Sent: Monday, August 31, 2009 10:37 AM
To: [email protected]
Subject: RE: [flexcoders] Why no event dispatched? 

Your event is not set to bubble, so you
listener must be: myLoginManagerInstance.addEventListener();  Is it?   Tracy 
Spratt,  Lariat Services, development services
available 
----------------------------------------
 From: [email protected] [mailto:[email protected]] On Behalf 
Of Wally Kolcz
Sent: Monday, August 31, 2009
12:09 PM
To:[email protected]
Subject: [flexcoders] Why no event
dispatched?      

Can anyone tell me what I am missing from this Class
that not dispatch the LoginEvent.FAILED?

package com.isavepets.rm.business

{

    import com.isavepets.rm.events.LoginEvent;

    import flash.events.EventDispatcher;

    import flash.events.IEventDispatcher;

    import mx.collections.ArrayCollection;

    public class LoginManager extends EventDispatcher

    {

        public var username:String;

        public var role:String;

        public var rescueID:int;

        public function LoginManager(target:IEventDispatcher=null)

        {

            super(target);

        }

        public function manageLogin(e:ArrayCollection):Boolean
{

            if (e.length !=0){

DataModel.getInstance().username = e.getItemAt(0).username;

DataModel.getInstance().role = e.getItemAt(0).role;

DataModel.getInstance().rescueID = e.getItemAt(0).rescueID;

return true;

            }else{

this.dispatchEvent(new LoginEvent(LoginEvent.FAILED));

                /*
Alert.show("Incorrect Username and/or Password, Please Try Again",
"Login Failed"); */

return false;

            }

        }

    }

}



Reply via email to