Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:18:37+00:00 2026-05-27T16:18:37+00:00

I’ve been trying this for a day now and I can’t work it out.

  • 0

I’ve been trying this for a day now and I can’t work it out.

I have a main application Planner.mxml. This view has a couple of custom components, one of which is LoginView.mxml. In LoginView.mxml I do the following:

protected function btnLoginClick(event:MouseEvent):void
{
    try
    {
        var login:Login = new Login(txtEmail.text, txtPassword.text);       
    } 
    catch(error:Error) 
    {
        Alert.show(error.message, "Oops!");
    }
}

I create a new instance of my Login class and send some parameters to the constructor. My constructor looks like this:

public function Login(email:String, password:String)
        {
            if(email == "" || password == "")
            {
                throw new Error("Please complete all fields.");
            }
            else
            {
                var loginRequest:HTTPService = new HTTPService();
                var parameters:Object = new Object();

                parameters.email = email;
                parameters.password = password;

                loginRequest.url = Globals.LOGIN_URL;
                loginRequest.resultFormat = "object";
                loginRequest.method = "POST";
                loginRequest.addEventListener("result", loginHandleResult);
                loginRequest.addEventListener("fault", loginHandleFault);
                loginRequest.send(parameters);
            }
        }

Here I check if all fields are complete, and if so, I put the constructor parameters in a parameters object which I then send to the HTTPService, which is a simple PHP file that handles the request, checks with the db and returns some xml. (This might not be the best way, but this really isn’t too important at this point).

If the user is logged in successfully, the xml will contain a status property which is set to true. I check for this in the result event handler of the HTTP service. This is where everything goes wrong though.

protected function loginHandleResult(event:ResultEvent):void
        {
            if(event.result.status == true)
            {
                trace("logged in");
 // here stuff goes wrong
                var e:LoggedInEvent = new LoggedInEvent("loggedIn");
                dispatchEvent(e);
            }
            else
            {
                trace("not logged in");
                Alert.show("Wrong credentials.", "Oops!");
            }
        }

As you can see, when the user is successfully logged in, I want to dispatch a custom event; if not, I show an alert box. However, this event doesn’t dispatch (or at least, I don’t know how to listen for it).

I would like to listen for it in my main application where I can then change my viewstate to the logged-in state. However, the event never seems to get there. I listen for it by having loggedIn="loggedInHandler(event)" on my loginComponent.

Any idea how to do this? Thanks in advance. I would really appreciate any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:18:38+00:00Added an answer on May 27, 2026 at 4:18 pm

    First, your Login needs to extend event dispatcher or implement IEventDispatcher. I’m not sure why you’re getting compiler errors trying to dispatch events from it.

    Next, you need to listen to the new Login instance for that event.

    However, you have an architectural problem here that your View should NOT be handling business logic and it should DEFINITELY not be creating new objects that are not its own children on the Display List.

    Instead, you should dispatch an event from the View that REQUESTS that a login occur, and then that request should be handled further up. Depending on the scale of your application, this can be the main mxml file or separate controller or Command logic. It is ok for the View to do a minimal amount of validation prior to dispatching the Event, but ideally you would want to encapsulate this stuff into a PresentationModel (because it is easier to test).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.